[videos] Fix saving imdb_id duplicates
This commit is contained in:
@ -3,6 +3,24 @@ from unittest.mock import MagicMock, patch
|
||||
from scrobbles.scrobblers import jellyfin_scrobble_media, mopidy_scrobble_media
|
||||
|
||||
|
||||
def test_jellyfin_scrobble_video_with_no_imdb_id():
|
||||
with patch("scrobbles.scrobblers.Video") as mock_video_class:
|
||||
mock_video_class.find_or_create.return_value = None
|
||||
|
||||
post_data = {
|
||||
"ItemType": "Video",
|
||||
"Name": "Test Video",
|
||||
"Provider_imdb": "",
|
||||
"PlaybackPosition": "00:05:00",
|
||||
"NotificationType": "PlaybackProgress",
|
||||
"UtcTimestamp": "2024-01-15T10:30:00Z",
|
||||
}
|
||||
|
||||
result = jellyfin_scrobble_media(post_data, 1)
|
||||
|
||||
mock_video_class.find_or_create.assert_called_once_with(None)
|
||||
|
||||
|
||||
def test_jellyfin_scrobble_media_ignores_progress_with_zero_position():
|
||||
|
||||
post_data = {
|
||||
|
||||
17
tests/videos_tests/test_video_find_or_create.py
Normal file
17
tests/videos_tests/test_video_find_or_create.py
Normal file
@ -0,0 +1,17 @@
|
||||
import pytest
|
||||
from videos.models import Video
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestVideoFindOrCreate:
|
||||
def test_find_or_create_with_none_returns_none(self):
|
||||
result = Video.find_or_create(None)
|
||||
assert result is None
|
||||
|
||||
def test_find_or_create_with_empty_string_returns_none(self):
|
||||
result = Video.find_or_create("")
|
||||
assert result is None
|
||||
|
||||
def test_find_or_create_with_invalid_id_returns_none(self):
|
||||
result = Video.find_or_create("invalid-id")
|
||||
assert result is None
|
||||
Reference in New Issue
Block a user