Add test for a album inside a album 👍

This commit is contained in:
Hellowlol 2017-10-25 20:58:20 +02:00
parent 7682a04c7b
commit f8e594ff3f
2 changed files with 13 additions and 2 deletions

View file

@ -46,6 +46,7 @@ class Photoalbum(PlexPartialObject):
self.type = data.attrib.get('type')
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
def albums(self, **kwargs):
""" Returns a list of :class:`~plexapi.photo.Photoalbum` objects in this album. """
key = '/library/metadata/%s/children' % self.ratingKey
@ -54,10 +55,11 @@ class Photoalbum(PlexPartialObject):
def album(self, title):
""" Returns the :class:`~plexapi.photo.Photoalbum` that matches the specified title. """
for album in self.albums():
if album.attrib.get('title').lower() == title.lower():
if album.title.lower() == title.lower():
return album
raise NotFound('Unable to find album: %s' % title)
def photos(self, **kwargs):
""" Returns a list of :class:`~plexapi.photo.Photo` objects in this album. """
key = '/library/metadata/%s/children' % self.ratingKey
@ -66,7 +68,7 @@ class Photoalbum(PlexPartialObject):
def photo(self, title):
""" Returns the :class:`~plexapi.photo.Photo` that matches the specified title. """
for photo in self.photos():
if photo.attrib.get('title').lower() == title.lower():
if photo.title.lower() == title.lower():
return photo
raise NotFound('Unable to find photo: %s' % title)

9
tests/test_photo.py Normal file
View file

@ -0,0 +1,9 @@
def test_photo_Photoalbum(photoalbum):
assert len(photoalbum.albums()) == 3
assert len(photoalbum.photos()) == 3
cats_in_bed = photoalbum.album('Cats in bed')
assert len(cats_in_bed.photos()) == 7
a_pic = cats_in_bed.photo('maxresdefault')
assert a_pic