Skip to content

Commit 24126fe

Browse files
author
renaud gaudin
committed
additional filtered-out values for hints
Also Added native int as Hint test (filtered) One may think that it would be valid to pass a dict with an int as key that matches the Hints in libzim's item.h. Those are filtered in pylibzim as not recognized as Hint objects. Also Removing duplicate test
1 parent ed3b5fa commit 24126fe

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

tests/test_libzim_creator.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -567,28 +567,15 @@ def get_mimetype(self):
567567
return ""
568568

569569
with Creator(fpath) as c:
570-
with pytest.raises(RuntimeError, match="has no attribute"):
570+
with pytest.raises(RuntimeError, match="has no attribute 'get_hints'"):
571571
c.add_item(AnItem())
572572

573573
with pytest.raises(RuntimeError, match="must be implemented"):
574574
c.add_item(libzim.writer.Item())
575575

576576

577577
def test_nondict_hints(fpath):
578-
class AnItem:
579-
def get_path(self):
580-
return ""
581-
582-
def get_title(self):
583-
return ""
584-
585-
def get_mimetype(self):
586-
return ""
587-
588578
with Creator(fpath) as c:
589-
with pytest.raises(RuntimeError, match="has no attribute 'get_hints'"):
590-
c.add_item(AnItem())
591-
592579
with pytest.raises(RuntimeError, match="has no attribute 'items'"):
593580
c.add_item(StaticItem(path="1", title="", hints=1))
594581

@@ -614,6 +601,11 @@ def test_hints_values(fpath):
614601
c.add_redirection(
615602
path="4", title="", targetPath="0", hints={Hint.COMPRESS: True}
616603
)
604+
# filtered-out values
605+
c.add_item(StaticItem(path="5", title="", hints={5: True}))
606+
c.add_item(StaticItem(path="6", title="", hints={"yolo": True}))
607+
c.add_item(StaticItem(path="7", title="", hints={"FRONT_ARTICLE": True}))
608+
c.add_item(StaticItem(path="8", title="", hints={0: True}))
617609

618610
# non-existent Hint
619611
with pytest.raises(AttributeError, match="YOLO"):

0 commit comments

Comments
 (0)