Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_person():
bryan = Person('Bryan Cranston')
assert bryan.name == 'Bryan Cranston'
assert bryan.birthday == '1956-03-07'
assert bryan.death is None
assert bryan.birthplace == 'San Fernando Valley, California, USA'
assert bryan.homepage == 'http://www.bryancranston.com/'
description='Some descriptive text',
privacy='public',
display_numbers=True)
# create list
l = UserList.create(creator=sean.username, **data)
for k, v in data.items():
assert getattr(l, k) == v
# get list
l = UserList.get(data['name'], sean.username)
l = sean.get_list(data['name'])
for k, v in data.items():
assert getattr(l, k) == v
# enumerate list items
instancetypes = (Movie, TVShow, TVSeason, TVEpisode, Person)
assert all([isinstance(k, instancetypes) for k in l])
# PUT to add and remove items from list
l.add_items()
for k, v in data.items():
assert getattr(l, k) == v
l.remove_items()
for k, v in data.items():
assert getattr(l, k) == v
# like and unlike a list
l.like()
l.unlike()
# just test to ensure that iterating over list items works
l.__iter__()
def test_movie_people():
tron = Movie('Tron Legacy', year=2010)
sub_groups = ['people', 'cast', 'crew']
for group in sub_groups:
persons = getattr(tron, group)
assert isinstance(persons, list)
assert len(persons) >= 1
assert isinstance(persons[0], Person)
assert all(isinstance(p, Person) for p in persons)
yield [Movie(**d.pop('movie')) for d in data]
elif search_type == 'show':
from trakt.tv import TVShow
yield [TVShow(**d.pop('show')) for d in data]
elif search_type == 'episode':
from trakt.tv import TVEpisode
episodes = []
for episode in data:
show = episode.pop('show')
extract_ids(episode['episode'])
episodes.append(TVEpisode(show.get('title', None),
**episode['episode']))
yield episodes
elif search_type == 'person':
from trakt.people import Person
yield [Person(**d.pop('person')) for d in data]
def people(self):
"""A :const:`list` of all of the :class:`People` involved in this
:class:`TVShow`, including both cast and crew
"""
if self._people is None:
data = yield (self.ext + '/people')
crew = data.get('crew', {})
cast = []
for c in data.get('cast', []):
person = c.pop('person')
character = c.pop('character')
cast.append(Person(character=character, **person))
_crew = []
for key in crew:
for department in crew.get(key): # lists
person = department.get('person')
person.update({'job': department.get('job')})
_crew.append(Person(**person))
self._people = cast + _crew
yield self._people
def remove_items(self, *items):
"""Remove *items* to this :class:`UserList`, where items is an iterable
"""
movies = [m.ids for m in items if isinstance(m, Movie)]
shows = [s.ids for s in items if isinstance(s, TVShow)]
people = [p.ids for p in items if isinstance(p, Person)]
self._items = items
args = {'movies': movies, 'shows': shows, 'people': people}
uri = 'users/{user}/lists/{id}/items/remove'.format(user=self.creator,
id=self.trakt)
yield uri, args
"""
if self._people is None:
data = yield (self.ext + '/people')
crew = data.get('crew', {})
cast = []
for c in data.get('cast', []):
person = c.pop('person')
character = c.pop('character')
cast.append(Person(character=character, **person))
_crew = []
for key in crew:
for department in crew.get(key): # lists
person = department.get('person')
person.update({'job': department.get('job')})
_crew.append(Person(**person))
self._people = cast + _crew
yield self._people
def people(self):
"""A :const:`list` of all of the :class:`People` involved in this
:class:`TVShow`, including both cast and crew
"""
if self._people is None:
data = yield (self.ext + '/people')
crew = data.get('crew', {})
cast = []
for c in data.get('cast', []):
person = c.pop('person')
character = c.pop('character')
cast.append(Person(character=character, **person))
_crew = []
for key in crew:
for department in crew.get(key): # lists
person = department.get('person')
person.update({'job': department.get('job')})
_crew.append(Person(**person))
self._people = cast + _crew
yield self._people
results = []
for d in data:
if 'episode' in d:
from trakt.tv import TVEpisode
show = d.pop('show')
extract_ids(d['episode'])
results.append(TVEpisode(show['title'], **d['episode']))
elif 'movie' in d:
from trakt.movies import Movie
results.append(Movie(**d.pop('movie')))
elif 'show' in d:
from trakt.tv import TVShow
results.append(TVShow(**d.pop('show')))
elif 'person' in d:
from trakt.people import Person
results.append(Person(**d.pop('person')))
yield results
results = []
for d in data:
if 'episode' in d:
from trakt.tv import TVEpisode
show = d.pop('show')
extract_ids(d['episode'])
results.append(TVEpisode(show['title'], **d['episode']))
elif 'movie' in d:
from trakt.movies import Movie
results.append(Movie(**d.pop('movie')))
elif 'show' in d:
from trakt.tv import TVShow
results.append(TVShow(**d.pop('show')))
elif 'person' in d:
from trakt.people import Person
results.append(Person(**d.pop('person')))
yield results