From 45ec546c21032561c33005e8b6486fac2a244be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 2 Nov 2022 17:50:55 +0200 Subject: [PATCH 1/2] Update methods to return api responses The responses may contain useful information what was updated: { 'added': { 'movies': 1, 'episodes': 0 }, 'not_found': { 'movies': [], 'shows': [], 'seasons': [], 'episodes': [], 'people': [], 'users': [] } } --- trakt/movies.py | 18 +++++++++--------- trakt/tv.py | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/trakt/movies.py b/trakt/movies.py index 5190a7b0..2e5ce58d 100644 --- a/trakt/movies.py +++ b/trakt/movies.py @@ -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""" @@ -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. @@ -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): diff --git a/trakt/tv.py b/trakt/tv.py index 0890d82d..015e08b2 100644 --- a/trakt/tv.py +++ b/trakt/tv.py @@ -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 @@ -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 @@ -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): From f230a8f8eb0452635821dfeebfc06a504267de4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 2 Nov 2022 21:29:15 +0200 Subject: [PATCH 2/2] Update tests to match signature The tests doesn't seem to be testing anything much other than coverage? --- tests/test_episodes.py | 4 ++-- tests/test_movies.py | 12 +++++++++--- tests/test_seasons.py | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/test_episodes.py b/tests/test_episodes.py index c3b82582..8a41f84f 100644 --- a/tests/test_episodes.py +++ b/tests/test_episodes.py @@ -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(): diff --git a/tests/test_movies.py b/tests/test_movies.py index f6156df7..da38e5b0 100644 --- a/tests/test_movies.py +++ b/tests/test_movies.py @@ -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(): diff --git a/tests/test_seasons.py b/tests/test_seasons.py index c69ef2a2..23a6bb22 100644 --- a/tests/test_seasons.py +++ b/tests/test_seasons.py @@ -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():