Reuse CV test data in comic_issue_result data. Cover possible empty volume data in get_volume_issues_info.

This commit is contained in:
Mizaki 2022-10-19 23:30:11 +01:00
parent e1ab72ec2a
commit 4be12d857d
2 changed files with 32 additions and 26 deletions

View File

@ -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],
)

View File

@ -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": "<i>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.</i>",
"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(