More test fixes that may need to be looked at further.

This commit is contained in:
Mizaki 2022-10-09 23:43:52 +01:00
parent ac15a4dd72
commit 18d861a2be
6 changed files with 38 additions and 22 deletions

View File

@ -354,7 +354,7 @@ class ComicCacher:
cover_date=row[5],
image=row[6],
description=row[8],
volume={"id": volume_id, "name": row[2]},
volume={"id": volume_id, "name": ""}, # Name isn't recorded
aliases=row[9],
)

View File

@ -13,6 +13,25 @@ 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,

View File

@ -16,7 +16,7 @@ def test_getPageNameList():
pageNameList = c.get_page_name_list()
assert pageNameList == [
"!cover.jpg",
"!cover.jpg", # Depending on locale puncuation or numbers might come first (Linux)
"00.jpg",
"page0.jpg",
"Page1.jpeg",

View File

@ -3,7 +3,6 @@ from __future__ import annotations
import pytest
import comictalker.comiccacher
import comictaggerlib.resulttypes
from testing.comicdata import alt_covers, search_results, select_details
@ -29,7 +28,7 @@ def test_alt_covers(comic_cache, alt_cover):
@pytest.mark.parametrize("volume_info", search_results)
def test_volume_info(comic_cache, volume_info):
comic_cache.add_volume_info(cv_volume_record=volume_info, source_name="test")
comic_cache.add_volume_info(volume_record=volume_info, source_name="test")
vi = volume_info.copy()
del vi["description"]
del vi["image"]

View File

@ -12,20 +12,17 @@ def test_search_for_series(comicvine_api, comic_cache):
ct = comictalker.talkers.comicvine.ComicVineTalker()
results = ct.search_for_series("cory doctorows futuristic tales of the here and now")
for r in results:
r["image"] = {"super_url": r["image"]["super_url"]}
r["start_year"] = int(r["start_year"])
del r["publisher"]["id"]
del r["publisher"]["api_detail_url"]
cache_issues = comic_cache.get_search_results(ct.source_name, "cory doctorows futuristic tales of the here and now")
assert results == cache_issues
def test_fetch_volume_data(comicvine_api, comic_cache):
ct = comictalker.talkers.comicvine.ComicVineTalker()
result = ct.fetch_volume_data(23437)
result = ct.fetch_partial_volume_data(23437)
result["start_year"] = int(result["start_year"])
del result["publisher"]["id"]
del result["publisher"]["api_detail_url"]
del result["description"]
del result["image"]
assert result == comic_cache.get_volume_info(23437, ct.source_name)
@ -34,26 +31,29 @@ def test_fetch_issues_by_volume(comicvine_api, comic_cache):
results = ct.fetch_issues_by_volume(23437)
cache_issues = comic_cache.get_volume_issues_info(23437, ct.source_name)
for r in results:
r["image"] = {"super_url": r["image"]["super_url"], "thumb_url": r["image"]["thumb_url"]}
del r["volume"]
del r["image_thumb"]
for c in cache_issues:
del c["volume"]
assert results == cache_issues
def test_fetch_issue_data_by_issue_id(comicvine_api, settings, mock_now, mock_version):
ct = comictalker.talkers.comicvine.ComicVineTalker()
result = ct.fetch_issue_data_by_issue_id(140529, settings)
result = ct.fetch_issue_data_by_issue_id(140529)
assert result == testing.comicvine.cv_md
def test_fetch_issues_by_volume_issue_num_and_year(comicvine_api):
ct = comictalker.talkers.comicvine.ComicVineTalker()
results = ct.fetch_issues_by_volume_issue_num_and_year([23437], "1", None)
cv_expected = testing.comicvine.cv_issue_result["results"].copy()
cv_expected = testing.comicvine.comic_issue_result.copy()
testing.comicvine.filter_field_list(
cv_expected,
{"params": {"field_list": "id,volume,issue_number,name,image,cover_date,site_detail_url,description,aliases"}},
)
for r, e in zip(results, [cv_expected]):
del r["image_thumb"]
assert r == e
@ -67,7 +67,7 @@ cv_issue = [
@pytest.mark.parametrize("volume_id, issue_number, expected", cv_issue)
def test_fetch_issue_data(comicvine_api, settings, mock_now, mock_version, volume_id, issue_number, expected):
ct = comictalker.talkers.comicvine.ComicVineTalker()
results = ct.fetch_issue_data(volume_id, issue_number, settings)
results = ct.fetch_issue_data(volume_id, issue_number)
assert results == expected

View File

@ -4,14 +4,13 @@ import pytest
import comicapi.comicarchive
import comicapi.issuestring
import comictalker.talkers.comicvine
import comictaggerlib.issueidentifier
import testing.comicdata
import testing.comicvine
def test_crop(cbz_double_cover, settings, tmp_path):
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz_double_cover, settings)
def test_crop(cbz_double_cover, settings, tmp_path, comicvine_api):
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz_double_cover, settings, comicvine_api)
cropped = ii.crop_cover(cbz_double_cover.archiver.read_file("double_cover.jpg"))
original_cover = cbz_double_cover.get_page(0)
@ -22,17 +21,16 @@ def test_crop(cbz_double_cover, settings, tmp_path):
@pytest.mark.parametrize("additional_md, expected", testing.comicdata.metadata_keys)
def test_get_search_keys(cbz, settings, additional_md, expected):
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz, settings)
def test_get_search_keys(cbz, settings, additional_md, expected, comicvine_api):
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz, settings, comicvine_api)
ii.set_additional_metadata(additional_md)
assert expected == ii.get_search_keys()
def test_get_issue_cover_match_score(cbz, settings, comicvine_api):
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz, settings)
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz, settings, comicvine_api)
score = ii.get_issue_cover_match_score(
comictalker.talkers.comicvine.ComicVineTalker(),
int(
comicapi.issuestring.IssueString(
cbz.read_metadata(comicapi.comicarchive.MetaDataStyle.CIX).issue
@ -52,7 +50,7 @@ def test_get_issue_cover_match_score(cbz, settings, comicvine_api):
def test_search(cbz, settings, comicvine_api):
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz, settings)
ii = comictaggerlib.issueidentifier.IssueIdentifier(cbz, settings, comicvine_api)
results = ii.search()
cv_expected = {
"series": f"{testing.comicvine.cv_volume_result['results']['name']} ({testing.comicvine.cv_volume_result['results']['start_year']})",