diff --git a/plexapi/server.py b/plexapi/server.py index e2b4d631..a55582bf 100644 --- a/plexapi/server.py +++ b/plexapi/server.py @@ -438,7 +438,7 @@ class PlexServer(PlexObject): log.debug('%s %s', method.__name__.upper(), url) headers = self._headers(**headers or {}) response = method(url, headers=headers, timeout=timeout, **kwargs) - if response.status_code not in (200, 201): + if response.status_code not in (200, 201, 204): codename = codes.get(response.status_code)[0] errtext = response.text.replace('\n', ' ') message = '(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext) diff --git a/tests/conftest.py b/tests/conftest.py index d1493002..da2ab134 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -323,6 +323,8 @@ def patched_http_call(mocker): # Utility Functions # --------------------------------- def is_datetime(value): + if value is None: + return True return value > MIN_DATETIME diff --git a/tests/test_audio.py b/tests/test_audio.py index 3abfdbe5..1e1e1d35 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -68,8 +68,7 @@ def test_audio_Album_attrs(album): assert utils.is_metadata(album.key) assert utils.is_int(album.librarySectionID) assert album.listType == "audio" - if album.originallyAvailableAt: - assert utils.is_datetime(album.originallyAvailableAt) + assert utils.is_datetime(album.originallyAvailableAt) assert utils.is_metadata(album.parentKey) assert utils.is_int(album.parentRatingKey) if album.parentThumb: @@ -223,8 +222,7 @@ def test_audio_Track_attrs(album): assert int(track.index) == 1 assert utils.is_metadata(track._initpath) assert utils.is_metadata(track.key) - if track.lastViewedAt: - assert utils.is_datetime(track.lastViewedAt) + assert utils.is_datetime(track.lastViewedAt) assert utils.is_int(track.librarySectionID) assert track.listType == "audio" # Assign 0 track.media diff --git a/tests/test_video.py b/tests/test_video.py index 89ac6ccb..df5fc97b 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -171,8 +171,7 @@ def test_video_Movie_attrs(movies): assert movie.guid == "com.plexapp.agents.imdb://tt1172203?lang=en" assert utils.is_metadata(movie._initpath) assert utils.is_metadata(movie.key) - if movie.lastViewedAt: - assert utils.is_datetime(movie.lastViewedAt) + assert utils.is_datetime(movie.lastViewedAt) assert int(movie.librarySectionID) >= 1 assert movie.listType == "video" assert movie.originalTitle is None @@ -496,8 +495,7 @@ def test_video_Show_attrs(show): assert utils.is_metadata(show._initpath) assert utils.is_int(show.index) assert utils.is_metadata(show.key) - if show.lastViewedAt: - assert utils.is_datetime(show.lastViewedAt) + assert utils.is_datetime(show.lastViewedAt) assert utils.is_int(show.leafCount) assert show.listType == "video" assert len(show.locations[0]) >= 10 @@ -770,8 +768,7 @@ def test_video_Season_attrs(show): assert season.index == 1 assert utils.is_metadata(season._initpath) assert utils.is_metadata(season.key) - if season.lastViewedAt: - assert utils.is_datetime(season.lastViewedAt) + assert utils.is_datetime(season.lastViewedAt) assert utils.is_int(season.leafCount, gte=3) assert season.listType == "video" assert utils.is_metadata(season.parentKey)