From c4d165664bd94ec07f288bbddf8ccf7da1558a7d Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 21:50:36 -0500 Subject: [PATCH 01/21] Update sonarr.py --- sonarr/sonarr.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 63cad1cb..b2204e5b 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -167,6 +167,19 @@ async def series(self) -> List[SeriesItem]: return [SeriesItem.from_dict(result) for result in results] + async def wanted(self, sortKey: str = "airDateUtc", page: int = 1, page_size: int = 10, sort: str = "asc") -> List[Episode]: + """Get wanted missing episodes.""" + params = { + "sortKey": sortKey, + "page": page, + "pageSize": page_size, + "sortDir": sort, + } + + results = await self._request("wanted/missing", params=params) + + return [Episode.from_dict(result) for result in results] + async def close(self) -> None: """Close open client session.""" if self._session and self._close_session: From 5b3ae2e09292a02556f1b8c47288ffc20c87b124 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:06:44 -0500 Subject: [PATCH 02/21] Update test_interface.py --- tests/test_interface.py | 99 ++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 66 deletions(-) diff --git a/tests/test_interface.py b/tests/test_interface.py index 5f3b80ce..ca495a45 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -51,28 +51,6 @@ async def test_app(aresponses): @pytest.mark.asyncio async def test_calendar(aresponses): """Test calendar is handled correctly.""" - aresponses.add( - MATCH_HOST, - "/api/system/status", - "GET", - aresponses.Response( - status=200, - headers={"Content-Type": "application/json"}, - text=load_fixture("system-status.json"), - ), - ) - - aresponses.add( - MATCH_HOST, - "/api/diskspace", - "GET", - aresponses.Response( - status=200, - headers={"Content-Type": "application/json"}, - text=load_fixture("diskspace.json"), - ), - ) - aresponses.add( MATCH_HOST, "/api/calendar?start=2014-01-26&end=2014-01-27", @@ -99,28 +77,6 @@ async def test_calendar(aresponses): @pytest.mark.asyncio async def test_queue(aresponses): """Test queue is handled correctly.""" - aresponses.add( - MATCH_HOST, - "/api/system/status", - "GET", - aresponses.Response( - status=200, - headers={"Content-Type": "application/json"}, - text=load_fixture("system-status.json"), - ), - ) - - aresponses.add( - MATCH_HOST, - "/api/diskspace", - "GET", - aresponses.Response( - status=200, - headers={"Content-Type": "application/json"}, - text=load_fixture("diskspace.json"), - ), - ) - aresponses.add( MATCH_HOST, "/api/queue", @@ -148,28 +104,6 @@ async def test_queue(aresponses): @pytest.mark.asyncio async def test_series(aresponses): """Test series is handled correctly.""" - aresponses.add( - MATCH_HOST, - "/api/system/status", - "GET", - aresponses.Response( - status=200, - headers={"Content-Type": "application/json"}, - text=load_fixture("system-status.json"), - ), - ) - - aresponses.add( - MATCH_HOST, - "/api/diskspace", - "GET", - aresponses.Response( - status=200, - headers={"Content-Type": "application/json"}, - text=load_fixture("diskspace.json"), - ), - ) - aresponses.add( MATCH_HOST, "/api/series", @@ -249,3 +183,36 @@ async def test_update(aresponses): assert response assert isinstance(response.info, models.Info) assert isinstance(response.disks, List) + + +@pytest.mark.asyncio +async def test_wanted(aresponses): + """Test queue is handled correctly.""" + aresponses.add( + MATCH_HOST, + "/api/wanted/missing", + "GET", + aresponses.Response( + status=200, + headers={"Content-Type": "application/json"}, + text=load_fixture("wanted-missing.json"), + ), + ) + + async with ClientSession() as session: + client = Sonarr(HOST, API_KEY, session=session) + response = await client.wanted() + + assert response + assert isinstance(response, WantedResult) + + assert response.per_page == 10 + assert response.total == 2 + assert response.sort == "asc" + + assert response.episodes + assert isinstance(response.episodes, List) + assert len(response.episodes) == 2 + + assert response.episodes[0] + assert isinstance(response.episodes[0], models.Episode) From 1aa273ded0a31ee39f0a187f1126880e6bd0a9ef Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:08:10 -0500 Subject: [PATCH 03/21] Update test_interface.py --- tests/test_interface.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_interface.py b/tests/test_interface.py index ca495a45..7d72e708 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -206,6 +206,7 @@ async def test_wanted(aresponses): assert response assert isinstance(response, WantedResult) + assert response.page == 1 assert response.per_page == 10 assert response.total == 2 assert response.sort == "asc" From 2317b291ef1c720a883bf99259adf99300ea5f8e Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:08:51 -0500 Subject: [PATCH 04/21] Update test_interface.py --- tests/test_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_interface.py b/tests/test_interface.py index 7d72e708..d311aa28 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -204,7 +204,7 @@ async def test_wanted(aresponses): response = await client.wanted() assert response - assert isinstance(response, WantedResult) + assert isinstance(response, models.WantedResults) assert response.page == 1 assert response.per_page == 10 From 4c560f886f1a5c70475a55129a2c14b95d149048 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:20:51 -0500 Subject: [PATCH 05/21] Update models.py --- sonarr/models.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sonarr/models.py b/sonarr/models.py index 714da085..fc7a45d0 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -252,6 +252,32 @@ def from_dict(data: dict): ) +@dataclass(frozen=True) +class WantedResults: + """Object holding wanted episode results from Sonarr.""" + + page: int + per_page: int + total: int + sort_key: str + sort_dir: str + episodes: List[Episode] + + @staticmethod + def from_dict(data: dict): + """Return WantedResults object from Sonarr API response.""" + episodes = [Episode.from_dict(episode) for episode in data.get("records", [])] + + return WantedResults( + page=data.get("page", 0), + per_page=data.get("pageSize", 0), + total=data.get("totalRecords", 0), + sort_key=data.get("sortKey", ""), + sort_dir=data.get("sortDir", ""), + episodes=episodes, + ) + + class Application: """Object holding all information of the Sonarr Application.""" From 4f0514f0b0bb7d37dbe3cc473aec5afddf111b88 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:24:41 -0500 Subject: [PATCH 06/21] Update sonarr.py --- sonarr/sonarr.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index b2204e5b..5e34b758 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -10,7 +10,13 @@ from .__version__ import __version__ from .exceptions import SonarrAccessRestricted, SonarrConnectionError, SonarrError -from .models import Application, Episode, QueueItem, SeriesItem +from .models import ( + Application, + Episode, + QueueItem, + SeriesItem, + WantedResults, +) class Sonarr: @@ -167,18 +173,20 @@ async def series(self) -> List[SeriesItem]: return [SeriesItem.from_dict(result) for result in results] - async def wanted(self, sortKey: str = "airDateUtc", page: int = 1, page_size: int = 10, sort: str = "asc") -> List[Episode]: + async def wanted( + self, sort_key: str = "airDateUtc", page: int = 1, page_size: int = 10, sort_dir: str = "asc" + ) -> WantedResults: """Get wanted missing episodes.""" params = { - "sortKey": sortKey, + "sortKey": sort_key, "page": page, "pageSize": page_size, - "sortDir": sort, + "sortDir": sort_dir, } results = await self._request("wanted/missing", params=params) - return [Episode.from_dict(result) for result in results] + return WantedResults.fromt_dict(results) async def close(self) -> None: """Close open client session.""" From e4bb5d396c4c5a3fc19dc9ba904276cc814a2bc0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:25:56 -0500 Subject: [PATCH 07/21] Update test_interface.py --- tests/test_interface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_interface.py b/tests/test_interface.py index d311aa28..a05a06bc 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -209,7 +209,8 @@ async def test_wanted(aresponses): assert response.page == 1 assert response.per_page == 10 assert response.total == 2 - assert response.sort == "asc" + assert response.sort_key == "airDateUtc" + assert response.sort_dir == "asc" assert response.episodes assert isinstance(response.episodes, List) From 73f92bd2ed84d6064f03edcc6655ab96ff49e1af Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:31:46 -0500 Subject: [PATCH 08/21] Update test_models.py --- tests/test_models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_models.py b/tests/test_models.py index c107412a..2cc31d70 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -14,6 +14,7 @@ DISKSPACE = json.loads(load_fixture("diskspace.json")) QUEUE = json.loads(load_fixture("queue.json")) SERIES = json.loads(load_fixture("series.json")) +WANTED = json.loads(load_fixture("wanted-missing.json")) APPLICATION = {"info": INFO, "diskspace": DISKSPACE} @@ -215,3 +216,21 @@ def test_series_item() -> None: assert item.seasons[3].total_episodes == 32 assert item.seasons[3].progress == 100 assert item.seasons[3].diskspace == 8000000000 + +def test_wanted_results() -> None: + """Test the WantedResults model.""" + results = WantedResults.from_dict(WANTED) + + assert results + assert results.page == 1 + assert results.per_page == 10 + assert results.total == 2 + assert results.sort_key == "airDateUtc" + assert results.sort_dir == "asc" + + assert results.episodes + assert isinstance(results.episodes, List) + assert len(results.episodes) == 2 + + assert results.episodes[0] + assert isinstance(results.episodes[0], models.Episode) From b10d256cd58652d87afbfc43d58979e25ef4424b Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 22:43:05 -0500 Subject: [PATCH 09/21] Create wanted-missing.json --- tests/fixtures/wanted-missing.json | 123 +++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 tests/fixtures/wanted-missing.json diff --git a/tests/fixtures/wanted-missing.json b/tests/fixtures/wanted-missing.json new file mode 100644 index 00000000..964863ef --- /dev/null +++ b/tests/fixtures/wanted-missing.json @@ -0,0 +1,123 @@ +{ + "page": 1, + "pageSize": 15, + "sortKey": "airDateUtc", + "sortDirection": "descending", + "totalRecords": 2, + "records": [ + { + "seriesId": 3, + "episodeFileId": 0, + "seasonNumber": 4, + "episodeNumber": 11, + "title": "Easy Com-mercial, Easy Go-mercial", + "airDate": "2014-01-26", + "airDateUtc": "2014-01-27T01:30:00Z", + "overview": "To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event, Bob is determined to create a Bob's Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.", + "hasFile": false, + "monitored": true, + "sceneEpisodeNumber": 0, + "sceneSeasonNumber": 0, + "tvDbEpisodeId": 0, + "series": { + "tvdbId": 194031, + "tvRageId": 24607, + "imdbId": "tt1561755", + "title": "Bob's Burgers", + "sortTitle": "bob burgers", + "cleanTitle": "bobsburgers", + "seasonCount": 4, + "status": "continuing", + "overview": "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success.", + "airTime": "17:30", + "monitored": true, + "qualityProfileId": 1, + "seasonFolder": true, + "lastInfoSync": "2014-01-26T19:25:55.455594Z", + "runtime": 30, + "images": [ + { + "coverType": "banner", + "url": "http://slurm.trakt.us/images/banners/1387.6.jpg" + }, + { + "coverType": "poster", + "url": "http://slurm.trakt.us/images/posters/1387.6-300.jpg" + }, + { + "coverType": "fanart", + "url": "http://slurm.trakt.us/images/fanart/1387.6.jpg" + } + ], + "seriesType": "standard", + "network": "FOX", + "useSceneNumbering": false, + "titleSlug": "bobs-burgers", + "certification": "TV-14", + "path": "T:\\Bob's Burgers", + "year": 2011, + "firstAired": "2011-01-10T01:30:00Z", + "genres": [ + "Animation", + "Comedy" + ], + "tags": [], + "added": "2011-01-26T19:25:55.455594Z", + "qualityProfile": { + "value": { + "name": "SD", + "allowed": [ + { + "id": 1, + "name": "SDTV", + "weight": 1 + }, + { + "id": 8, + "name": "WEBDL-480p", + "weight": 2 + }, + { + "id": 2, + "name": "DVD", + "weight": 3 + } + ], + "cutoff": { + "id": 1, + "name": "SDTV", + "weight": 1 + }, + "id": 1 + }, + "isLoaded": true + }, + "seasons": [ + { + "seasonNumber": 4, + "monitored": true + }, + { + "seasonNumber": 3, + "monitored": true + }, + { + "seasonNumber": 2, + "monitored": true + }, + { + "seasonNumber": 1, + "monitored": true + }, + { + "seasonNumber": 0, + "monitored": false + } + ], + "id": 66 + }, + "downloading": false, + "id": 14402 + } + ] +} From bf6e9a5e0f0fee3617aa8f88bd6a3ee039df5c8d Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 23:03:21 -0500 Subject: [PATCH 10/21] Update wanted-missing.json --- tests/fixtures/wanted-missing.json | 130 +++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/tests/fixtures/wanted-missing.json b/tests/fixtures/wanted-missing.json index 964863ef..92e699bf 100644 --- a/tests/fixtures/wanted-missing.json +++ b/tests/fixtures/wanted-missing.json @@ -118,6 +118,136 @@ }, "downloading": false, "id": 14402 + }, + { + "seriesId": 17, + "episodeFileId": 0, + "seasonNumber": 1, + "episodeNumber": 1, + "title": "The New Housekeeper", + "airDate": "1960-10-03", + "airDateUtc": "1960-10-03T01:00:00Z", + "overview": "Sheriff Andy Taylor and his young son Opie are in need of a new housekeeper. Andy's Aunt Bee looks like the perfect candidate and moves in, but her presence causes friction with Opie."", + "hasFile": false, + "monitored": true, + "sceneEpisodeNumber": 0, + "sceneSeasonNumber": 0, + "tvDbEpisodeId": 0, + "series": { + "imdbId": "", + "tvdbId": 77754, + "tvRageId": 5574, + "tvMazeId": 3853, + "title": "The Andy Griffith Show"", + "sortTitle": "andy griffith show", + "cleanTitle": "theandygriffithshow", + "seasonCount": 8, + "status": "ended", + "overview": "Down-home humor and an endearing cast of characters helped make The Andy Griffith Show one of the most beloved comedies in the history of TV. The show centered around widower Andy Taylor, who divided his time between raising his young son Opie, and his job as sheriff of the sleepy North Carolina town, Mayberry. Andy and Opie live with Andy's Aunt Bee, who serves as a surrogate mother to both father and son. Andy's nervous cousin, Barney Fife, is his deputy sheriff whose incompetence is tolerated because Mayberry is virtually crime-free.", + "airTime": "21:30", + "monitored": true, + "qualityProfileId": 1, + "seasonFolder": true, + "lastInfoSync": "2016-02-05T16:40:11.614176Z", + "runtime": 25, + "images": [ + { + "coverType": "fanart", + "url": "https://artworks.thetvdb.com/banners/fanart/original/77754-5.jpg" + }, + { + "coverType": "banner", + "url": "https://artworks.thetvdb.com/banners/graphical/77754-g.jpg" + }, + { + "coverType": "poster", + "url": "https://artworks.thetvdb.com/banners/posters/77754-4.jpg" + } + ], + "seriesType": "standard", + "network": "CBS", + "useSceneNumbering": false, + "titleSlug": "the-andy-griffith-show", + "certification": "TV-G", + "path": "F:\\The Andy Griffith Show", + "year": 1960, + "firstAired": "1960-02-15T06:00:00Z", + "genres": [ + "Comedy" + ], + "tags": [], + "added": "2008-02-04T13:44:24.204583Z", + "qualityProfile": { + "value": { + "name": "SD", + "allowed": [ + { + "id": 1, + "name": "SDTV", + "weight": 1 + }, + { + "id": 8, + "name": "WEBDL-480p", + "weight": 2 + }, + { + "id": 2, + "name": "DVD", + "weight": 3 + } + ], + "cutoff": { + "id": 1, + "name": "SDTV", + "weight": 1 + }, + "id": 1 + }, + "isLoaded": true + }, + "seasons": [ + { + "seasonNumber": 0, + "monitored": false + }, + { + "seasonNumber": 1, + "monitored": false + }, + { + "seasonNumber": 2, + "monitored": true + }, + { + "seasonNumber": 3, + "monitored": false + }, + { + "seasonNumber": 4, + "monitored": false + }, + { + "seasonNumber": 5, + "monitored": true + }, + { + "seasonNumber": 6, + "monitored": true + }, + { + "seasonNumber": 7, + "monitored": true + }, + { + "seasonNumber": 8, + "monitored": true + } + ], + "id": 17 + }, + "downloading": false, + "id": 889 } ] } From 33f11ad31259a7f77fa3581960ba0c1e8bf10200 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 23:07:50 -0500 Subject: [PATCH 11/21] Update wanted-missing.json --- tests/fixtures/wanted-missing.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/wanted-missing.json b/tests/fixtures/wanted-missing.json index 92e699bf..8c218fa4 100644 --- a/tests/fixtures/wanted-missing.json +++ b/tests/fixtures/wanted-missing.json @@ -127,7 +127,7 @@ "title": "The New Housekeeper", "airDate": "1960-10-03", "airDateUtc": "1960-10-03T01:00:00Z", - "overview": "Sheriff Andy Taylor and his young son Opie are in need of a new housekeeper. Andy's Aunt Bee looks like the perfect candidate and moves in, but her presence causes friction with Opie."", + "overview": "Sheriff Andy Taylor and his young son Opie are in need of a new housekeeper. Andy's Aunt Bee looks like the perfect candidate and moves in, but her presence causes friction with Opie.", "hasFile": false, "monitored": true, "sceneEpisodeNumber": 0, From da2808951910202a507c26fba58a11dc2e34a5a8 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 23:11:19 -0500 Subject: [PATCH 12/21] Update wanted-missing.json --- tests/fixtures/wanted-missing.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/wanted-missing.json b/tests/fixtures/wanted-missing.json index 8c218fa4..013328a4 100644 --- a/tests/fixtures/wanted-missing.json +++ b/tests/fixtures/wanted-missing.json @@ -138,7 +138,7 @@ "tvdbId": 77754, "tvRageId": 5574, "tvMazeId": 3853, - "title": "The Andy Griffith Show"", + "title": "The Andy Griffith Show", "sortTitle": "andy griffith show", "cleanTitle": "theandygriffithshow", "seasonCount": 8, From c9049688122193ccf1d2d9d49f691c821036bee1 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 23:18:43 -0500 Subject: [PATCH 13/21] Update sonarr.py --- sonarr/sonarr.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 5e34b758..4802d89c 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -10,13 +10,7 @@ from .__version__ import __version__ from .exceptions import SonarrAccessRestricted, SonarrConnectionError, SonarrError -from .models import ( - Application, - Episode, - QueueItem, - SeriesItem, - WantedResults, -) +from .models import Application, Episode, QueueItem, SeriesItem, WantedResults class Sonarr: @@ -179,14 +173,14 @@ async def wanted( """Get wanted missing episodes.""" params = { "sortKey": sort_key, - "page": page, - "pageSize": page_size, + "page": str(page), + "pageSize": str(page_size), "sortDir": sort_dir, } results = await self._request("wanted/missing", params=params) - return WantedResults.fromt_dict(results) + return WantedResults.from_dict(results) async def close(self) -> None: """Close open client session.""" From 04e3b78dabc05b5f654f38fd60806b04b26ac1fa Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 23:21:57 -0500 Subject: [PATCH 14/21] Update sonarr.py --- sonarr/sonarr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 4802d89c..50714dfb 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -168,7 +168,11 @@ async def series(self) -> List[SeriesItem]: return [SeriesItem.from_dict(result) for result in results] async def wanted( - self, sort_key: str = "airDateUtc", page: int = 1, page_size: int = 10, sort_dir: str = "asc" + self, + sort_key: str = "airDateUtc", + page: int = 1, + page_size: int = 10, + sort_dir: str = "asc" ) -> WantedResults: """Get wanted missing episodes.""" params = { From 1047a945ab24330ba93e25abacf7cd8ddf861a86 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 5 Apr 2020 23:22:26 -0500 Subject: [PATCH 15/21] Update test_models.py --- tests/test_models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 2cc31d70..8f60866f 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -217,9 +217,10 @@ def test_series_item() -> None: assert item.seasons[3].progress == 100 assert item.seasons[3].diskspace == 8000000000 + def test_wanted_results() -> None: """Test the WantedResults model.""" - results = WantedResults.from_dict(WANTED) + results = models.WantedResults.from_dict(WANTED) assert results assert results.page == 1 From 4a4cd4aa645ec3a242d9e8de4e240f5c0f765838 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Mon, 6 Apr 2020 10:34:01 -0500 Subject: [PATCH 16/21] Update sonarr.py --- sonarr/sonarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 50714dfb..3806a329 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -172,7 +172,7 @@ async def wanted( sort_key: str = "airDateUtc", page: int = 1, page_size: int = 10, - sort_dir: str = "asc" + sort_dir: str = "asc", ) -> WantedResults: """Get wanted missing episodes.""" params = { From 4a254372c88a6efb0014791fc5742d6eba2c2f25 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Mon, 6 Apr 2020 10:47:55 -0500 Subject: [PATCH 17/21] Update wanted-missing.json --- tests/fixtures/wanted-missing.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/wanted-missing.json b/tests/fixtures/wanted-missing.json index 013328a4..5db7c52f 100644 --- a/tests/fixtures/wanted-missing.json +++ b/tests/fixtures/wanted-missing.json @@ -1,6 +1,6 @@ { "page": 1, - "pageSize": 15, + "pageSize": 10, "sortKey": "airDateUtc", "sortDirection": "descending", "totalRecords": 2, From 266a53a0724a1ca7374c401e750c4dc971e4c83f Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Mon, 6 Apr 2020 10:55:15 -0500 Subject: [PATCH 18/21] Update models.py --- sonarr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/models.py b/sonarr/models.py index fc7a45d0..30d5bb4d 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -273,7 +273,7 @@ def from_dict(data: dict): per_page=data.get("pageSize", 0), total=data.get("totalRecords", 0), sort_key=data.get("sortKey", ""), - sort_dir=data.get("sortDir", ""), + sort_dir=data.get("sortDirection", ""), episodes=episodes, ) From 00a4473a61a19f6a5f2f94931614c14703f6ca66 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Mon, 6 Apr 2020 11:03:01 -0500 Subject: [PATCH 19/21] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 8f60866f..7f507992 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -227,7 +227,7 @@ def test_wanted_results() -> None: assert results.per_page == 10 assert results.total == 2 assert results.sort_key == "airDateUtc" - assert results.sort_dir == "asc" + assert results.sort_dir == "descending" assert results.episodes assert isinstance(results.episodes, List) From b3b8c2d2f6543ecca41eda632697fdd0b2873469 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Mon, 6 Apr 2020 11:03:23 -0500 Subject: [PATCH 20/21] Update test_interface.py --- tests/test_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_interface.py b/tests/test_interface.py index a05a06bc..ba6bbde0 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -210,7 +210,7 @@ async def test_wanted(aresponses): assert response.per_page == 10 assert response.total == 2 assert response.sort_key == "airDateUtc" - assert response.sort_dir == "asc" + assert response.sort_dir == "descending" assert response.episodes assert isinstance(response.episodes, List) From 1f8cd47d42ce0d22713e4859da8d39bd1a9ab02b Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Mon, 6 Apr 2020 11:04:05 -0500 Subject: [PATCH 21/21] Update sonarr.py --- sonarr/sonarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 3806a329..b25aef4d 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -172,7 +172,7 @@ async def wanted( sort_key: str = "airDateUtc", page: int = 1, page_size: int = 10, - sort_dir: str = "asc", + sort_dir: str = "desc", ) -> WantedResults: """Get wanted missing episodes.""" params = {