Skip to content

Commit

Permalink
Feature: Update methods to return api responses (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Nov 2, 2022
2 parents f82cfcc + f230a8f commit c5f3047
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
4 changes: 2 additions & 2 deletions tests/test_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ def test_oneliners():
e1.remove_from_collection, e1.remove_from_watchlist]
for fn in functions:
r = fn()
assert r is None
assert r is not None


def test_episode_comment():
e1 = TVEpisode('Game of Thrones', season=1, number=1)
r = e1.comment('Test Comment')
assert r is None
assert r is not None


def test_episode_scrobble():
Expand Down
12 changes: 9 additions & 3 deletions tests/test_movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,27 @@ def test_movie_search():
assert all(isinstance(m, Movie) for m in results)


def test_dismiss():
tron = Movie('Tron Legacy 2010')
r = tron.dismiss()
assert r is None


def test_utilities():
tron = Movie('Tron Legacy 2010')
functions = [tron.add_to_library, tron.add_to_collection,
tron.add_to_watchlist, tron.dismiss, tron.mark_as_unseen,
tron.add_to_watchlist, tron.mark_as_unseen,
tron.remove_from_library, tron.remove_from_collection,
tron.remove_from_watchlist, tron.mark_as_seen]
for fn in functions:
r = fn()
assert r is None
assert r is not None


def test_movie_comment():
tron = Movie('Tron Legacy 2010')
r = tron.comment('Some comment data')
assert r is None
assert r is not None


def test_rate_movie():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_oneliners():
s1.remove_from_library, s1.remove_from_collection]
for fn in functions:
r = fn()
assert r is None
assert r is not None


def test_season_to_json():
Expand Down
18 changes: 9 additions & 9 deletions trakt/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ def watching_now(self):

def add_to_library(self):
"""Add this :class:`Movie` to your library."""
add_to_collection(self)
return add_to_collection(self)
add_to_collection = add_to_library

def add_to_watchlist(self):
"""Add this :class:`Movie` to your watchlist"""
add_to_watchlist(self)
return add_to_watchlist(self)

def comment(self, comment_body, spoiler=False, review=False):
"""Add a comment (shout or review) to this :class:`Move` on trakt."""
comment(self, comment_body, spoiler, review)
return comment(self, comment_body, spoiler, review)

def dismiss(self):
"""Dismiss this movie from showing up in Movie Recommendations"""
Expand Down Expand Up @@ -305,28 +305,28 @@ def get_translations(self, country_code='us'):
def mark_as_seen(self, watched_at=None):
"""Add this :class:`Movie`, watched outside of trakt, to your library.
"""
add_to_history(self, watched_at)
return add_to_history(self, watched_at)

def mark_as_unseen(self):
"""Remove this :class:`Movie`, watched outside of trakt, from your
library.
"""
remove_from_history(self)
return remove_from_history(self)

def rate(self, rating):
"""Rate this :class:`Movie` on trakt. Depending on the current users
settings, this may also send out social updates to facebook, twitter,
tumblr, and path.
"""
rate(self, rating)
return rate(self, rating)

def remove_from_library(self):
"""Remove this :class:`Movie` from your library."""
remove_from_collection(self)
return remove_from_collection(self)
remove_from_collection = remove_from_library

def remove_from_watchlist(self):
remove_from_watchlist(self)
return remove_from_watchlist(self)

def scrobble(self, progress, app_version, app_date):
"""Notify trakt that the current user has finished watching a movie.
Expand Down Expand Up @@ -362,7 +362,7 @@ def checkin(self, app_version, app_date, message="", sharing=None,
"""
if delete:
delete_checkin()
checkin_media(self, app_version, app_date, message, sharing, venue_id,
return checkin_media(self, app_version, app_date, message, sharing, venue_id,
venue_name)

def to_json_singular(self):
Expand Down
22 changes: 11 additions & 11 deletions trakt/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,13 @@ def watching_now(self):

def add_to_library(self):
"""Add this :class:`TVSeason` to your library."""
add_to_collection(self)
return add_to_collection(self)

add_to_collection = add_to_library

def remove_from_library(self):
"""Remove this :class:`TVSeason` from your library."""
remove_from_collection(self)
return remove_from_collection(self)

remove_from_collection = remove_from_library

Expand Down Expand Up @@ -864,40 +864,40 @@ def rate(self, rating):
settings, this may also send out social updates to facebook, twitter,
tumblr, and path.
"""
rate(self, rating)
return rate(self, rating)

def add_to_library(self):
"""Add this :class:`TVEpisode` to your Trakt.tv library"""
add_to_collection(self)
return add_to_collection(self)

add_to_collection = add_to_library

def add_to_watchlist(self):
"""Add this :class:`TVEpisode` to your watchlist"""
add_to_watchlist(self)
return add_to_watchlist(self)

def mark_as_seen(self, watched_at=None):
"""Mark this episode as seen"""
add_to_history(self, watched_at)
return add_to_history(self, watched_at)

def mark_as_unseen(self):
"""Remove this :class:`TVEpisode` from your list of watched episodes"""
remove_from_history(self)
return remove_from_history(self)

def remove_from_library(self):
"""Remove this :class:`TVEpisode` from your library"""
remove_from_collection(self)
return remove_from_collection(self)

remove_from_collection = remove_from_library

def remove_from_watchlist(self):
"""Remove this :class:`TVEpisode` from your watchlist"""
remove_from_watchlist(self)
return remove_from_watchlist(self)

def comment(self, comment_body, spoiler=False, review=False):
"""Add a comment (shout or review) to this :class:`TVEpisode` on trakt.
"""
comment(self, comment_body, spoiler, review)
return comment(self, comment_body, spoiler, review)

def scrobble(self, progress, app_version, app_date):
"""Scrobble this :class:`TVEpisode` via the TraktTV Api
Expand Down Expand Up @@ -930,7 +930,7 @@ def checkin(self, app_version, app_date, message="", sharing=None,
"""
if delete:
delete_checkin()
checkin_media(self, app_version, app_date, message, sharing, venue_id,
return checkin_media(self, app_version, app_date, message, sharing, venue_id,
venue_name)

def to_json_singular(self):
Expand Down

0 comments on commit c5f3047

Please sign in to comment.