Skip to content

Commit 1583e4f

Browse files
committed
Add missing test in PR#178 to remain at 100% coverage
1 parent 6eb77a5 commit 1583e4f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/zim/test_indexing.py

+20
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,23 @@ def test_indexing_item_pdf_custom_title(tmp_path, encrypted_pdf_file):
332332
assert reader.get_search_results_count("the") == 1
333333
assert reader.get_search_results_count("microsoft") == 1
334334
assert reader.get_search_results_count("c8clark") == 1
335+
336+
337+
@pytest.mark.parametrize(
338+
"content, wordcount, expected_wordcount",
339+
[
340+
("foo", None, 1),
341+
("foo bar", None, 2),
342+
(" foo bar ", None, 2),
343+
(
344+
"foo bar",
345+
123,
346+
123,
347+
), # wordcount is passed so it is not automatically computed
348+
],
349+
)
350+
def test_index_data_wordcount(content, wordcount, expected_wordcount):
351+
assert (
352+
IndexData(title="foo", content=content, wordcount=wordcount).get_wordcount()
353+
== expected_wordcount
354+
)

tests/zim/test_zim_creator.py

+8
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ def test_check_metadata(tmp_path):
535535
with pytest.raises(ValueError, match="Counter cannot be set"):
536536
Creator(tmp_path, "").config_dev_metadata(Counter=1).start()
537537

538+
with pytest.raises(ValueError, match="Invalid type for Foo"):
539+
Creator(tmp_path, "").config_dev_metadata(Foo=1).start()
540+
538541
with pytest.raises(ValueError, match="Description is too long."):
539542
Creator(tmp_path, "").config_dev_metadata(Description="T" * 90).start()
540543

@@ -750,6 +753,10 @@ def test_config_metadata_control_characters(tmp_path):
750753
"Creator_1",
751754
" A creator ",
752755
)
756+
creator.add_metadata(
757+
"Binary1",
758+
bytes.fromhex("01FA"),
759+
)
753760
pass
754761

755762
assert fpath.exists()
@@ -773,6 +780,7 @@ def test_config_metadata_control_characters(tmp_path):
773780
== "A description \rwith \ncontrol characters\tsss"
774781
)
775782
assert reader.get_text_metadata("Creator_1") == "A creator"
783+
assert bytes.hex(reader.get_metadata("Binary1")) == "01fa"
776784

777785

778786
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)