Beispiel #1
0
def test_retrieve_single_issue(talker, fake_comic, metron_response, mocker):
    # Remove any existing metadata from comic fixture
    ca = ComicArchive(fake_comic)
    if ca.has_metadata():
        ca.remove_metadata()

    # Mock the call to Metron
    mocker.patch.object(Session, "issue", return_value=metron_response)
    talker.retrieve_single_issue(fake_comic, 10)

    # Now let's test the metadata
    ca = ComicArchive(fake_comic)
    assert ca.has_metadata()
    ca_md = ca.read_metadata()
    assert ca_md.title == list_to_string(list(metron_response.story_titles))
    assert ca_md.series == metron_response.series.name
    assert ca_md.volume == str(metron_response.volume)
    assert ca_md.publisher == metron_response.publisher.name
    assert ca_md.issue == metron_response.number
    assert ca_md.story_arc == list_to_string([a.name for a in metron_response.arcs])
    assert ca_md.teams == list_to_string([t.name for t in metron_response.teams])
    assert ca_md.year == str(metron_response.cover_date.year)
    assert ca_md.characters == list_to_string([c.name for c in metron_response.characters])
    assert ca_md.credits is not None
    assert ca_md.credits[0]["person"] == "Al Milgrom"
    assert ca_md.credits[0]["role"] == "Cover"
Beispiel #2
0
    def _map_resp_to_metadata(self, resp) -> GenericMetadata:
        md = GenericMetadata()

        if resp.credits:
            md = self._add_credits_to_metadata(md, resp.credits)

        md.series = resp.series.name
        md.volume = resp.volume
        md.issue = IssueString(resp.number).as_string()
        md.publisher = resp.publisher.name
        md.day = resp.cover_date.day
        md.month = resp.cover_date.month
        md.year = resp.cover_date.year
        md.comments = resp.desc
        md.notes = self._create_note(resp.id)

        if resp.story_titles:
            md.title = list_to_string(list(resp.story_titles))

        if resp.characters:
            md.characters = list_to_string([c.name for c in resp.characters])

        if resp.teams:
            md.teams = list_to_string([t.name for t in resp.teams])

        if resp.arcs:
            md.story_arc = list_to_string([a.name for a in resp.arcs])

        return md
Beispiel #3
0
def test_map_resp_to_metadata(talker, metron_response):
    md = talker._map_resp_to_metadata(metron_response)
    assert md is not None
    assert md.title == list_to_string(list(metron_response.story_titles))
    assert md.series == metron_response.series.name
    assert md.volume == metron_response.volume
    assert md.publisher == metron_response.publisher.name
    assert md.issue == metron_response.number
    assert md.story_arc == list_to_string([a.name for a in metron_response.arcs])
    assert md.teams == list_to_string([t.name for t in metron_response.teams])
    assert md.year == metron_response.cover_date.year
    assert md.characters == list_to_string([c.name for c in metron_response.characters])
    assert md.credits is not None
    assert md.credits[0]["person"] == "Al Milgrom"
    assert md.credits[0]["role"] == "Cover"
def test_list_to_string():
    thislist = ["apple", "banana", "cherry"]
    expected_result = "apple; banana; cherry"

    result = utils.list_to_string(thislist)
    assert result == expected_result