Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyheppell committed Aug 9, 2024
1 parent ac8d7ad commit fa95874
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/download/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] == "<test>"
assert unencoded[1]["field"] == "unencoded"
assert unencoded == [{"id": 1, "field": "<test>"}, {"id": 2, "field": "unencoded"}]

unencoded2 = Exporter.setup_export(entries, [["field"]])
assert unencoded2 == [{"id": 1, "field": "<test>"}, {"id": 2, "field": "unencoded"}]


def test_setup_escaping_nested():
entries = [{"id": 1, "parent": {"child": "&lt;test&gt;"}}]
entries = [{"id": 1, "parent": {"child": "&lt;test&gt;", "sibling": "test"}}]

unencoded = Exporter.setup_export(entries, [["parent", "child"]])
assert unencoded == [{"id": 1, "parent": {"child": "<test>", "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"] == "<test>"
assert unencoded == [{"id": 1, "parent": {"child": 1, "sibling": "test"}}]
8 changes: 8 additions & 0 deletions tests/parse/translations/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] == []

0 comments on commit fa95874

Please sign in to comment.