diff --git a/tests/download/test_exporter.py b/tests/download/test_exporter.py index 32f4fa2..21fb496 100644 --- a/tests/download/test_exporter.py +++ b/tests/download/test_exporter.py @@ -5,12 +5,20 @@ def test_setup_escaping(): entries = [{"id": 1, "field": "<test>"}, {"id": 2, "field": "unencoded"}] unencoded = Exporter.setup_export(entries, ["field"]) - assert unencoded[0]["field"] == "" - assert unencoded[1]["field"] == "unencoded" + assert unencoded == [{"id": 1, "field": ""}, {"id": 2, "field": "unencoded"}] + + unencoded2 = Exporter.setup_export(entries, [["field"]]) + assert unencoded2 == [{"id": 1, "field": ""}, {"id": 2, "field": "unencoded"}] def test_setup_escaping_nested(): - entries = [{"id": 1, "parent": {"child": "<test>"}}] + entries = [{"id": 1, "parent": {"child": "<test>", "sibling": "test"}}] + + unencoded = Exporter.setup_export(entries, [["parent", "child"]]) + assert unencoded == [{"id": 1, "parent": {"child": "", "sibling": "test"}}] + +def test_escape_unescapable(): + entries = [{"id": 1, "parent": {"child": 1, "sibling": "test"}}] unencoded = Exporter.setup_export(entries, [["parent", "child"]]) - assert unencoded[0]["parent"]["child"] == "" + assert unencoded == [{"id": 1, "parent": {"child": 1, "sibling": "test"}}] diff --git a/tests/parse/translations/test_extractor.py b/tests/parse/translations/test_extractor.py index f3d1480..ed555cc 100644 --- a/tests/parse/translations/test_extractor.py +++ b/tests/parse/translations/test_extractor.py @@ -48,3 +48,11 @@ def test_error_extracting(caplog, parsed_page): assert res.iloc[0] is None assert "but failed to select element with: .dummy" in caplog.text + + +def test_doc_is_done(): + res = extract_translations( + None, "https://example.org/current-lang-page/", translation_pickers=None + ) + assert res.iloc[0] is None + assert res.iloc[1] == []