Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Dec 9, 2024
1 parent d3280d6 commit a64c439
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/client/test_identifier_resolution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from caselawclient.identifier_resolution import IdentifierResolutions

raw_marklogic_resolutions = [
"""
{"documents.compiled_url_slugs.identifier_uuid":"24b9a384-8bcf-4f20-996a-5c318f8dc657",
"documents.compiled_url_slugs.document_uri":"/ewca/civ/2003/547.xml",
"documents.compiled_url_slugs.identifier_slug":"ewca/civ/2003/54721",
"documents.compiled_url_slugs.document_published":"false"}
""",
"""
{"documents.compiled_url_slugs.identifier_uuid":"x",
"documents.compiled_url_slugs.document_uri":"x",
"documents.compiled_url_slugs.identifier_slug":"x",
"documents.compiled_url_slugs.document_published":"true"}
""",
]


def test_decoded_identifier():
decoded_resolutions = IdentifierResolutions.from_marklogic_output(raw_marklogic_resolutions)
res = decoded_resolutions[0]
assert res.identifier_uuid == "24b9a384-8bcf-4f20-996a-5c318f8dc657"
assert res.document_uri == "/ewca/civ/2003/547.xml"
assert res.identifier_slug == "ewca/civ/2003/54721"
assert res.document_published == False # noqa: E712


def test_published():
decoded_resolutions = IdentifierResolutions.from_marklogic_output(raw_marklogic_resolutions)
assert len(decoded_resolutions.published()) == 1
assert decoded_resolutions.published()[0] == decoded_resolutions[1]

0 comments on commit a64c439

Please sign in to comment.