From 4be12d857d2a204b047a522005258de2c7179e7d Mon Sep 17 00:00:00 2001 From: Mizaki Date: Wed, 19 Oct 2022 23:30:11 +0100 Subject: [PATCH] Reuse CV test data in comic_issue_result data. Cover possible empty volume data in get_volume_issues_info. --- comictalker/comiccacher.py | 22 +++++++++++++++------- testing/comicvine.py | 36 +++++++++++++++++------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/comictalker/comiccacher.py b/comictalker/comiccacher.py index f6d8351..f1a173b 100644 --- a/comictalker/comiccacher.py +++ b/comictalker/comiccacher.py @@ -359,6 +359,14 @@ class ComicCacher: # now process the results for row in rows: volume_info = self.get_search_results(source_name, "", volume_id, False) + # Cover if it comes back empty + if not volume_info: + volume_info = [ + ComicVolume( + id=volume_id, + name="", + ) + ] record = ComicIssue( id=row[1], name=row[2], @@ -368,14 +376,14 @@ class ComicCacher: image=row[6], description=row[8], volume=ComicVolume( - aliases=volume_info[0]["aliases"], - count_of_issues=volume_info[0]["count_of_issues"], + aliases=volume_info[0].get("aliases", ""), + count_of_issues=volume_info[0].get("count_of_issues", 0), id=volume_id, - name=volume_info[0]["name"], - description=volume_info[0]["description"], - image=volume_info[0]["image"], - publisher=volume_info[0]["publisher"], - start_year=volume_info[0]["start_year"], + name=volume_info[0].get("name", ""), + description=volume_info[0].get("description", ""), + image=volume_info[0].get("image", ""), + publisher=volume_info[0].get("publisher", ""), + start_year=volume_info[0].get("start_year", 0), ), aliases=row[9], ) diff --git a/testing/comicvine.py b/testing/comicvine.py index 24641a6..b102e3a 100644 --- a/testing/comicvine.py +++ b/testing/comicvine.py @@ -13,25 +13,6 @@ def filter_field_list(cv_result, kwargs): del cv_result[key] -comic_issue_result: dict[str, Any] = { - "aliases": None, - "cover_date": "2007-10-01", - "description": "For 12-year-old Anda, getting paid real money to kill the characters of players who were cheating in her favorite online computer game was a win-win situation. Until she found out who was paying her, and what those characters meant to the livelihood of children around the world.", - "id": 140529, - "image": "https://comicvine.gamespot.com/a/uploads/scale_large/0/574/585444-109004_20080707014047_large.jpg", - "image_thumb": "https://comicvine.gamespot.com/a/uploads/scale_avatar/0/574/585444-109004_20080707014047_large.jpg", - "issue_number": "1", - "name": "Anda's Game", - "site_detail_url": "https://comicvine.gamespot.com/cory-doctorows-futuristic-tales-of-the-here-and-no/4000-140529/", - "volume": { - "api_detail_url": "https://comicvine.gamespot.com/api/volume/4050-23437/", - "id": 23437, - "name": "Cory Doctorow's Futuristic Tales of the Here and Now", - "site_detail_url": "https://comicvine.gamespot.com/cory-doctorows-futuristic-tales-of-the-here-and-no/4050-23437/", - }, -} - - cv_issue_result: dict[str, Any] = { "error": "OK", "limit": 1, @@ -175,6 +156,23 @@ cv_not_found = { "status_code": 101, "results": [], } +comic_issue_result: dict[str, Any] = { + "aliases": cv_issue_result["results"]["aliases"], + "cover_date": cv_issue_result["results"]["cover_date"], + "description": cv_issue_result["results"]["description"], + "id": cv_issue_result["results"]["id"], + "image": cv_issue_result["results"]["image"]["super_url"], + "image_thumb": cv_issue_result["results"]["image"]["thumb_url"], + "issue_number": cv_issue_result["results"]["issue_number"], + "name": cv_issue_result["results"]["name"], + "site_detail_url": cv_issue_result["results"]["site_detail_url"], + "volume": { + "api_detail_url": cv_issue_result["results"]["volume"]["api_detail_url"], + "id": cv_issue_result["results"]["volume"]["id"], + "name": cv_issue_result["results"]["volume"]["name"], + "site_detail_url": cv_issue_result["results"]["volume"]["site_detail_url"], + }, +} date = comictalker.talkers.comicvine.ComicVineTalker().parse_date_str(cv_issue_result["results"]["cover_date"]) cv_md = comicapi.genericmetadata.GenericMetadata(