Add tests for prepare_metadata
This commit is contained in:
parent
8b4bf8d51f
commit
d63123b77b
@ -19,15 +19,23 @@ def prepare_metadata(md: GenericMetadata, new_md: GenericMetadata, opts: Settngs
|
||||
final_md = GenericMetadata()
|
||||
|
||||
final_md.overlay(new_md)
|
||||
assert final_md.tag_origin
|
||||
notes = (
|
||||
f"Tagged with ComicTagger {ctversion.version} using info from {final_md.tag_origin.name} on"
|
||||
f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {final_md.issue_id}]"
|
||||
)
|
||||
if final_md.tag_origin is not None:
|
||||
notes = (
|
||||
f"Tagged with ComicTagger {ctversion.version} using info from {final_md.tag_origin.name} on"
|
||||
+ f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {final_md.issue_id}]"
|
||||
)
|
||||
else:
|
||||
notes = (
|
||||
f"Tagged with ComicTagger {ctversion.version} on"
|
||||
+ f" {datetime.now():%Y-%m-%d %H:%M:%S}. "
|
||||
+ (f"[Issue ID {final_md.issue_id}]" if final_md.issue_id else "")
|
||||
)
|
||||
|
||||
if opts.Issue_Identifier__auto_imprint:
|
||||
final_md.fix_publisher()
|
||||
|
||||
return final_md.replace(
|
||||
notes=utils.combine_notes(new_md.notes, notes, "Tagged with ComicTagger"),
|
||||
description=cleanup_html(new_md.description, opts.Sources__remove_html_tables),
|
||||
is_empty=False,
|
||||
notes=utils.combine_notes(final_md.notes, notes, "Tagged with ComicTagger"),
|
||||
description=cleanup_html(final_md.description, opts.Sources__remove_html_tables) or None,
|
||||
)
|
||||
|
@ -135,3 +135,30 @@ all_seed_imprints = {
|
||||
all_seed_imprints["Marvel"].update(additional_seed_imprints["Marvel"])
|
||||
|
||||
conflicting_seed_imprints = {"Marvel": {"test": "Never"}}
|
||||
|
||||
|
||||
metadata_prepared = (
|
||||
(
|
||||
(comicapi.genericmetadata.GenericMetadata(), comicapi.genericmetadata.GenericMetadata()),
|
||||
comicapi.genericmetadata.GenericMetadata(notes="Tagged with ComicTagger 1.3.2a5 on 2022-04-16 15:52:26."),
|
||||
),
|
||||
(
|
||||
(comicapi.genericmetadata.GenericMetadata(issue_id="123"), comicapi.genericmetadata.GenericMetadata()),
|
||||
comicapi.genericmetadata.GenericMetadata(
|
||||
issue_id="123", notes="Tagged with ComicTagger 1.3.2a5 on 2022-04-16 15:52:26. [Issue ID 123]"
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
comicapi.genericmetadata.GenericMetadata(
|
||||
issue_id="123", tag_origin=comicapi.genericmetadata.TagOrigin("SOURCE", "Source")
|
||||
),
|
||||
comicapi.genericmetadata.GenericMetadata(),
|
||||
),
|
||||
comicapi.genericmetadata.GenericMetadata(
|
||||
issue_id="123",
|
||||
tag_origin=comicapi.genericmetadata.TagOrigin("SOURCE", "Source"),
|
||||
notes="Tagged with ComicTagger 1.3.2a5 using info from Source on 2022-04-16 15:52:26. [Issue ID 123]",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -4,6 +4,8 @@ import pytest
|
||||
from importlib_metadata import entry_points
|
||||
|
||||
import comicapi.genericmetadata
|
||||
import testing.comicdata
|
||||
from comictaggerlib.md import prepare_metadata
|
||||
|
||||
metadata_styles = []
|
||||
|
||||
@ -38,3 +40,9 @@ def test_metadata(mock_version, tmp_comic, md_saved, metadata):
|
||||
written_metadata = written_metadata.get_clean_metadata(*supported_attributes)
|
||||
|
||||
assert written_metadata == md
|
||||
|
||||
|
||||
@pytest.mark.parametrize("metadata, expected", testing.comicdata.metadata_prepared)
|
||||
def test_prepare_metadata(mock_version, mock_now, config, metadata, expected):
|
||||
new_md = prepare_metadata(metadata[0], metadata[1], config[0])
|
||||
assert new_md == expected
|
||||
|
Loading…
Reference in New Issue
Block a user