Fix tests

This commit is contained in:
Michael Shepanski 2017-02-04 14:18:10 -05:00
parent 7c766337b6
commit cf99256450
3 changed files with 28 additions and 21 deletions

View file

@ -6,6 +6,7 @@ from plexapi.compat import quote, string_type, urlencode
from plexapi.exceptions import NotFound, NotImplementedError, UnknownType, Unsupported
# Search Types - Plex uses these to filter specific media types when searching.
# Library Types - Populated at runtime
SEARCHTYPES = {'movie': 1, 'show': 2, 'season': 3, 'episode': 4,
'artist': 8, 'album': 9, 'track': 10, 'photo': 14}
LIBRARY_TYPES = {}
@ -65,10 +66,16 @@ class PlexPartialObject(object):
return '<%s:%s:%s>' % (clsname, key, title)
def __getattr__(self, attr):
# Auto reload self, from the full key (path) when needed.
if attr == 'key' or self.__dict__.get(attr) or self.isFullObject():
from plexapi import log
# Auto reload from the full key (path) when needed.
if attr == 'key' or self.__dict__.get(attr) or self.isFullObject() or attr.startswith('_'):
return self.__dict__.get(attr)
print('reload because of %s' % attr)
# Log warning about reloading the objects
clsname = self.__class__.__name__
title = self.__dict__.get('title') or self.__dict__.get('name')
objname = "%s '%s'" % (clsname, title) if title else clsname
log.warn("Reloading %s for attr '%s'" % (objname, attr))
# Reload the object
self.reload()
return self.__dict__.get(attr)

View file

@ -62,11 +62,11 @@ def test_audio_Album_attrs(a_music_album):
assert str(m.originallyAvailableAt.date()) == '2016-01-01'
assert m.parentKey == '/library/metadata/20'
assert m.parentRatingKey == '20'
assert str(m.parentThumb) == '__NA__'
assert m.parentThumb is None
assert m.parentTitle == 'Infinite State'
assert m.ratingKey == 21
assert m.server.baseurl == 'http://138.68.157.5:32400'
assert str(m.studio) == '__NA__'
assert m.studio is None
assert m.summary == ''
assert m.thumb == '/library/metadata/21/thumb/1484693407'
assert m.title == 'Unmastered Impulses'
@ -184,19 +184,19 @@ def test_audio_Track_attrs(a_music_album):
track = a_music_album.get('Holy Moment')
track.reload()
assert str(track.addedAt.date()) == '2017-01-17'
assert str(track.art) == '__NA__'
assert str(track.chapterSource) == '__NA__'
assert track.art is None
assert track.chapterSource is None
assert track.duration == 298606
assert str(track.grandparentArt) == '__NA__'
assert track.grandparentArt is None
assert track.grandparentKey == '/library/metadata/20'
assert track.grandparentRatingKey == '20'
assert str(track.grandparentThumb) == '__NA__'
assert track.grandparentThumb is None
assert track.grandparentTitle == 'Infinite State'
assert track.guid == 'local://22'
assert track.index == '1'
assert track.initpath == '/library/metadata/22'
assert track.key == '/library/metadata/22'
assert str(track.lastViewedAt) == '__NA__'
assert track.lastViewedAt is None
assert track.librarySectionID == '3'
assert track.listType == 'audio'
# Assign 0 track.media
@ -209,12 +209,12 @@ def test_audio_Track_attrs(a_music_album):
assert track.parentThumb == '/library/metadata/21/thumb/1484693407'
assert track.parentTitle == 'Unmastered Impulses'
assert track.player is None
assert str(track.playlistItemID) == '__NA__'
assert str(track.primaryExtraKey) == '__NA__'
assert track.playlistItemID is None
assert track.primaryExtraKey is None
assert track.ratingCount == 9
assert track.ratingKey == 22
assert track.server.baseurl == 'http://138.68.157.5:32400'
assert str(track.sessionKey) == '__NA__'
assert track.sessionKey is None
assert track.summary == ''
assert track.thumb == '/library/metadata/21/thumb/1484693407'
assert track.title == 'Holy Moment'
@ -225,8 +225,8 @@ def test_audio_Track_attrs(a_music_album):
assert track.username is None
assert track.viewCount == 0
assert track.viewOffset == 0
assert str(track.viewedAt) == '__NA__'
assert str(track.year) == '__NA__'
assert track.viewedAt is None
assert track.year is None
assert med0.aspectRatio is None
assert med0.audioChannels == 2
assert med0.audioCodec == 'mp3'

View file

@ -70,18 +70,18 @@ def test_video_Movie_attrs_as_much_as_possible(a_movie_section):
assert m.listType == 'video'
# Assign 0 m.media
med0 = m.media[0]
assert str(m.originalTitle) == '__NA__'
assert m.originalTitle is None
assert str(m.originallyAvailableAt.date()) == '2006-06-09'
assert m.player is None
assert str(m.playlistItemID) == '__NA__'
assert str(m.primaryExtraKey) == '__NA__'
assert m.playlistItemID is None
assert m.primaryExtraKey is None
#assert m.producers == [<Producer:130:Darla.K..Anderson>]
assert m.rating == '7.4'
assert m.ratingImage == 'rottentomatoes://image.rating.certified'
assert m.ratingKey == 2
assert [i.tag for i in m.roles] == ['Owen Wilson', 'Paul Newman', 'Bonnie Hunt', 'Larry the Cable Guy', 'Cheech Marin', 'Tony Shalhoub', 'Guido Quaroni', 'Jenifer Lewis', 'Paul Dooley', 'Michael Wallis', 'George Carlin', 'Katherine Helmond', 'John Ratzenberger', 'Michael Keaton', 'Joe Ranft', 'Richard Petty', 'Jeremy Piven', 'Bob Costas', 'Darrell Waltrip', 'Richard Kind', 'Edie McClurg', 'Humpy Wheeler', 'Tom Magliozzi', 'Ray Magliozzi', 'Lynda Petty', 'Andrew Stanton', 'Dale Earnhardt Jr.', 'Michael Schumacher', 'Jay Leno', 'Sarah Clark', 'Mike Nelson', 'Joe Ranft', 'Jonas Rivera', 'Lou Romano', 'Adrian Ochoa', 'E.J. Holowicki', 'Elissa Knight', 'Lindsey Collins', 'Larry Benton', 'Douglas Keever', 'Tom Hanks', 'Tim Allen', 'John Ratzenberger', 'Billy Crystal', 'John Goodman', 'John Ratzenberger', 'Dave Foley', 'John Ratzenberger', 'Vanness Wu']
assert m.server.baseurl == 'http://138.68.157.5:32400'
assert str(m.sessionKey) == '__NA__'
assert m.sessionKey is None
assert m.studio == 'Walt Disney Pictures'
assert m.summary == u"Lightning McQueen, a hotshot rookie race car driven to succeed, discovers that life is about the journey, not the finish line, when he finds himself unexpectedly detoured in the sleepy Route 66 town of Radiator Springs. On route across the country to the big Piston Cup Championship in California to compete against two seasoned pros, McQueen gets to know the town's offbeat characters."
assert m.tagline == "Ahhh... it's got that new movie smell."
@ -91,13 +91,13 @@ def test_video_Movie_attrs_as_much_as_possible(a_movie_section):
assert m.transcodeSession is None
assert m.type == 'movie'
assert str(m.updatedAt.date()) == '2017-01-17'
assert str(m.userRating) == '__NA__'
assert m.userRating is None
assert m.username is None
# Assign 0 m.videoStreams
vid0 = m.videoStreams[0]
assert m.viewCount == 0
assert m.viewOffset == 88870
assert str(m.viewedAt) == '__NA__'
assert m.viewedAt is None
assert [i.tag for i in m.writers] == ['Dan Fogelman', 'Joe Ranft', 'John Lasseter', 'Kiel Murray', 'Phil Lorin', 'Jorgen Klubien']
assert m.year == 2006
assert aud0.audioChannelLayout == '5.1'