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_episode_watching_now():
e1 = TVEpisode('Game of Thrones', season=1, number=1)
assert all([isinstance(u, User) for u in e1.watching_now])
def test_requests():
getters = [get_all_requests, User('sean').get_follower_requests]
for getter in getters:
requests = getter()
assert isinstance(requests, list)
assert all([isinstance(r, Request) for r in requests])
for request in requests:
r = request.approve()
assert r is None
r = request.deny()
assert r is None
def test_watching():
got = TVShow('Game of Thrones')
assert all(isinstance(u, User) for u in got.watching_now)
def test_user_watchlists():
sean = User('sean')
for _ in range(2):
assert all([isinstance(m, Movie) for m in sean.watchlist_movies])
assert all([isinstance(s, TVShow) for s in sean.watchlist_shows])
def setUp(self):
"""Grab environment information for validation"""
self.user = User(os.environ['TRAKT_TEST_USER'])
def test_stats():
sean = User('sean')
assert isinstance(sean.get_stats(), dict)
def test_watching():
sean = User('sean')
sean.username = 'sean-movie'
assert isinstance(sean.watching, Movie)
sean.username = 'sean-episode'
assert isinstance(sean.watching, TVEpisode)
sean.username = 'sean-nothing'
assert sean.watching is None
def get_all_requests():
"""Get a list of all follower requests including the timestamp when the
request was made. Use the approve and deny methods to manage each request.
"""
data = yield 'users/requests'
request_list = []
for request in data:
request['user'] = User(**request.pop('user'))
request_list.append(Request(**request))
yield request_list
def comments(self):
"""All comments (shouts and reviews) for this :class:`TVSeason`. Most
recent comments returned first.
"""
# TODO (jnappi) Pagination
from .users import User
data = yield (self.ext + '/comments')
self._comments = []
for com in data:
user = User(**com.pop('user'))
comment = Comment(user=user, **com)
self._comments.append(comment)
yield self._comments
def watching_now(self):
"""A list of all :class:`User`'s watching a movie."""
from .users import User
data = yield self.ext + '/watching'
users = []
for user in data:
users.append(User(**user))
yield users