Handle empty datetimes in tests

This commit is contained in:
Jason Lawrence 2020-10-08 15:15:43 -05:00
parent 7dad2a8931
commit 576dc21992
3 changed files with 7 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -169,8 +169,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
@ -494,8 +493,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
@ -768,8 +766,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)