Compare commits

..

2 Commits

Author SHA1 Message Date
9a9d97f3bb Fix #291
ComicTagger now accounts for any single unicode numeric value
2022-05-14 01:59:44 -07:00
a4cb8b51a6 Restore test cbz
Add test to ensure that metadata is read correctly
Add tests for IssueString
2022-05-14 01:59:39 -07:00
5 changed files with 40 additions and 10 deletions

View File

@ -383,12 +383,12 @@ md_test.characters = "Anda"
md_test.teams = "Fahrenheit"
md_test.locations = "lonely cottage "
md_test.credits = [
{"person": "Dara Naraghi", "role": "Writer"},
{"person": "Esteve Polls", "role": "Penciller"},
{"person": "Esteve Polls", "role": "Inker"},
{"person": "Neil Uyetake", "role": "Letterer"},
{"person": "Sam Kieth", "role": "Cover"},
{"person": "Ted Adams", "role": "Editor"},
CreditMetadata({"primary": False, "person": "Dara Naraghi", "role": "Writer"}),
CreditMetadata({"primary": False, "person": "Esteve Polls", "role": "Penciller"}),
CreditMetadata({"primary": False, "person": "Esteve Polls", "role": "Inker"}),
CreditMetadata({"primary": False, "person": "Neil Uyetake", "role": "Letterer"}),
CreditMetadata({"primary": False, "person": "Sam Kieth", "role": "Cover"}),
CreditMetadata({"primary": False, "person": "Ted Adams", "role": "Editor"}),
]
md_test.tags = []
md_test.pages = [
@ -417,7 +417,7 @@ md_test.pages = [
{"Image": 22, "ImageHeight": "2039", "ImageSize": "675078", "ImageWidth": "1326"},
{
"Bookmark": "Interview",
"Image": "23",
"Image": 23,
"ImageHeight": "2032",
"ImageSize": "800965",
"ImageWidth": "1338",

View File

@ -21,6 +21,7 @@ comics industry throws at us.
import logging
import unicodedata
logger = logging.getLogger(__name__)
@ -113,9 +114,8 @@ class IssueString:
def as_float(self):
# return the float, with no suffix
if self.suffix == "½":
if self.num is not None:
return self.num + 0.5
if len(self.suffix) == 1 and self.suffix.isnumeric():
return (self.num or 0) + unicodedata.numeric(self.suffix)
return 0.5
return self.num

20
tests/issuestring_test.py Normal file
View File

@ -0,0 +1,20 @@
import pytest
import comicapi.issuestring
issues = [
("¼", 0.25),
("", 1.5),
("0.5", 0.5),
("0", 0.0),
("1", 1.0),
("22.BEY", 22.0),
("22A", 22.0),
("22-A", 22.0),
]
@pytest.mark.parametrize("issue, expected", issues)
def test_issue_string_as_float(issue, expected):
issue_float = comicapi.issuestring.IssueString(issue).as_float()
assert issue_float == expected

View File

@ -42,6 +42,16 @@ def test_page_type_read():
assert isinstance(md.pages[0]["Type"], str)
def test_metadat_read():
c = ComicArchive(
join(thisdir, "data", "Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz")
)
md = c.read_cix()
md_dict = md.__dict__
md_test_dict = md_test.__dict__
assert md_dict == md_test_dict
def test_save_cix(tmpdir):
comic_path = tmpdir.mkdir("cbz").join(
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz"