From 2eca743f206c1c28e4a43d7aec20af34ee6e4cf7 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sun, 18 Feb 2024 15:52:35 -0800 Subject: [PATCH] Fix #602 Tests were not made correctly to catch the change in 2c3a2566cce1a871cbc3c2058a0d34ea9490dc16 This has now been corrected --- comictalker/talkers/comicvine.py | 4 +++- testing/comicvine.py | 10 +++++++--- tests/comicvinetalker_test.py | 1 + tests/integration_test.py | 11 +++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/comictalker/talkers/comicvine.py b/comictalker/talkers/comicvine.py index 7611dd9..013adef 100644 --- a/comictalker/talkers/comicvine.py +++ b/comictalker/talkers/comicvine.py @@ -668,7 +668,9 @@ class ComicVineTalker(ComicTalker): md.story_arcs.append(arc["name"]) for person in issue.get("person_credits", []): - md.add_credit(person["name"], person["role"].title().strip(), False) + roles = utils.split(person.get("role", ""), ",") + for role in roles: + md.add_credit(person["name"], role.title(), False) md.volume = utils.xlate_int(issue.get("volume")) if self.use_series_start_as_volume: diff --git a/testing/comicvine.py b/testing/comicvine.py index 1edad87..e7265b1 100644 --- a/testing/comicvine.py +++ b/testing/comicvine.py @@ -69,7 +69,7 @@ cv_issue_result: dict[str, Any] = { "id": 57222, "name": "Esteve Polls", "site_detail_url": "https://comicvine.gamespot.com/esteve-polls/4040-57222/", - "role": "artist", + "role": "artist, writer", }, { "api_detail_url": "https://comicvine.gamespot.com/api/person/4040-48472/", @@ -226,8 +226,12 @@ cv_md = comicapi.genericmetadata.GenericMetadata( teams=set(), locations=set(), credits=[ - comicapi.genericmetadata.Credit(person=x["name"], role=x["role"].title(), primary=False) - for x in cv_issue_result["results"]["person_credits"] + comicapi.genericmetadata.Credit(primary=False, person="Dara Naraghi", role="Writer"), + comicapi.genericmetadata.Credit(primary=False, person="Esteve Polls", role="Artist"), + comicapi.genericmetadata.Credit(primary=False, person="Esteve Polls", role="Writer"), + comicapi.genericmetadata.Credit(primary=False, person="Neil Uyetake", role="Letterer"), + comicapi.genericmetadata.Credit(primary=False, person="Sam Kieth", role="Cover"), + comicapi.genericmetadata.Credit(primary=False, person="Ted Adams", role="Editor"), ], tags=set(), pages=[], diff --git a/tests/comicvinetalker_test.py b/tests/comicvinetalker_test.py index 467e48e..8129c2a 100644 --- a/tests/comicvinetalker_test.py +++ b/tests/comicvinetalker_test.py @@ -42,6 +42,7 @@ def test_fetch_issues_in_series(comicvine_api, comic_cache): def test_fetch_issue_data_by_issue_id(comicvine_api): result = comicvine_api.fetch_comic_data(140529) result.notes = None + assert result == testing.comicvine.cv_md diff --git a/tests/integration_test.py b/tests/integration_test.py index 4d82a57..b375835 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -49,6 +49,17 @@ def test_save( # Read the CBZ md = tmp_comic.read_metadata("cr") + # This is inserted here because otherwise several other tests + # unrelated to comicvine need to be re-worked + md_saved.credits.insert( + 1, + { + "person": "Esteve Polls", + "primary": False, + "role": "Writer", + }, + ) + # Validate that we got the correct metadata back assert md == md_saved