From 379b8ff63b89edd5f8e97bbe88bc49cf5765f492 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Sun, 23 Apr 2017 01:54:53 -0400 Subject: [PATCH] Tests now pass for both test servers --- tests/conftest.py | 5 ++++- tests/test_audio.py | 6 ++++-- tests/test_library.py | 11 ++++++----- tests/test_server.py | 4 ++-- tests/test_video.py | 13 +++++++------ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f7e48667..9e417e21 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -112,7 +112,10 @@ def episode(show): @pytest.fixture() def photoalbum(photos): - return photos.get('Cats') + try: + return photos.get('Cats') + except: + return photos.get('photo_album1') @pytest.fixture() diff --git a/tests/test_audio.py b/tests/test_audio.py index affd5010..d17c650c 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -63,7 +63,8 @@ def test_audio_Album_attrs(album): assert album.originallyAvailableAt == datetime(2016, 1, 1) assert utils.is_metadata(album.parentKey) assert utils.is_int(album.parentRatingKey) - assert utils.is_metadata(album.parentThumb, contains='/thumb/') + if album.parentThumb: + assert utils.is_metadata(album.parentThumb, contains='/thumb/') assert album.parentTitle == 'Infinite State' assert album.ratingKey >= 1 assert album._server._baseurl == utils.SERVER_BASEURL @@ -192,7 +193,8 @@ def test_audio_Track_attrs(album): assert track.grandparentArt is None assert utils.is_metadata(track.grandparentKey) assert utils.is_int(track.grandparentRatingKey) - assert utils.is_metadata(track.grandparentThumb, contains='/thumb/') + if track.grandparentThumb: + assert utils.is_metadata(track.grandparentThumb, contains='/thumb/') assert track.grandparentTitle == 'Infinite State' assert track.guid.startswith('local://') assert int(track.index) == 1 diff --git a/tests/test_library.py b/tests/test_library.py index 876c6cd7..19b8cb3e 100644 --- a/tests/test_library.py +++ b/tests/test_library.py @@ -168,14 +168,15 @@ def test_library_MusicSection_searchAlbums(music): assert len(music.searchAlbums(title='Unmastered Impulses')) -def test_library_PhotoSection_searchAlbums(photos): - albums = photos.searchAlbums('Cats') +def test_library_PhotoSection_searchAlbums(photos, photoalbum): + title = photoalbum.title + albums = photos.searchAlbums(title) assert len(albums) - print([i.TYPE for i in albums]) -def test_library_PhotoSection_searchPhotos(photos): - assert len(photos.searchPhotos('CatBed')) +def test_library_PhotoSection_searchPhotos(photos, photoalbum): + title = photoalbum.photos()[0].title + assert len(photos.searchPhotos(title)) # Start on library search diff --git a/tests/test_server.py b/tests/test_server.py index c3f94435..0d2867ad 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -102,12 +102,12 @@ def test_server_playlist(plex, show): def test_server_playlists(plex, show): playlists = plex.playlists() - assert len(playlists) == 0 + count = len(playlists) episodes = show.episodes() playlist = plex.createPlaylist('test_playlist', episodes[:3]) try: playlists = plex.playlists() - assert len(playlists) == 1 + assert len(playlists) == count + 1 finally: playlist.delete() diff --git a/tests/test_video.py b/tests/test_video.py index 5b456d31..4cf9a78f 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -66,15 +66,16 @@ def test_video_Movie_attrs(movies): assert movie.chapterSource == 'agent' assert movie.collections == [] assert movie.contentRating == 'G' - assert [i.tag for i in movie.countries] == ['USA'] + assert all([i.tag in ['US', 'USA'] for i in movie.countries]) assert [i.tag for i in movie.directors] == ['John Lasseter', 'Joe Ranft'] - assert movie.duration >= 3600000 + assert movie.duration >= 160000 assert movie.fields == [] assert sorted([i.tag for i in movie.genres]) == ['Adventure', 'Animation', 'Comedy', 'Family', 'Sport'] assert movie.guid == 'com.plexapp.agents.imdb://tt0317219?lang=en' assert utils.is_metadata(movie._initpath) assert utils.is_metadata(movie.key) - assert movie.lastViewedAt is None + if movie.lastViewedAt: + assert utils.is_datetime(movie.lastViewedAt) assert int(movie.librarySectionID) >= 1 assert movie.listType == 'video' assert movie.originalTitle is None @@ -101,7 +102,7 @@ def test_video_Movie_attrs(movies): assert movie.userRating is None assert movie.username is None assert movie.viewCount == 0 - assert movie.viewOffset == 0 + assert utils.is_int(movie.viewOffset, gte=0) assert movie.viewedAt is None assert sorted([i.tag for i in movie.writers]) == ['Dan Fogelman', 'Joe Ranft', 'John Lasseter', 'Jorgen Klubien', 'Kiel Murray', 'Phil Lorin'] # noqa assert movie.year == 2006 @@ -134,7 +135,7 @@ def test_video_Movie_attrs(movies): assert media.audioCodec in utils.CODECS assert utils.is_int(media.bitrate) assert media.container in utils.CONTAINERS - assert utils.is_int(media.duration, gte=3600000) + assert utils.is_int(media.duration, gte=160000) assert utils.is_int(media.height) assert utils.is_int(media.id) assert utils.is_metadata(media._initpath) @@ -176,7 +177,7 @@ def test_video_Movie_attrs(movies): # Part part = media.parts[0] assert part.container in utils.CONTAINERS - assert utils.is_int(part.duration, 1600000) + assert utils.is_int(part.duration, 160000) assert len(part.file) >= 10 assert utils.is_int(part.id) assert utils.is_metadata(part._initpath)