test_debug_export_file.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. from pathlib import Path
  2. from app.models import AtlasAlias, AtlasClaim, AtlasClaimObject, AtlasEntity, AtlasProvenance
  3. from app.triple_export import entity_to_turtle
  4. def test_debug_turtle_can_be_written_to_file(tmp_path: Path):
  5. entity = AtlasEntity(
  6. atlas_id="atlas:012gx2abcd123456",
  7. canonical_label="Joe Biden",
  8. entity_type="Person",
  9. aliases=[AtlasAlias(label="Joe Biden")],
  10. claims=[
  11. AtlasClaim(
  12. claim_id="clm_raw_ident_mid_/m/012gx2",
  13. subject="atlas:012gx2abcd123456",
  14. predicate="atlas:hasIdentifier",
  15. object=AtlasClaimObject(kind="identifier", id_type="mid", value="/m/012gx2"),
  16. layer="raw",
  17. provenance=AtlasProvenance(source="google-trends", retrieval_method="trends-resolution", confidence=0.9, retrieved_at="2026-04-03T17:33:21.651528+00:00"),
  18. )
  19. ],
  20. needs_curation=False,
  21. )
  22. turtle = entity_to_turtle(entity)
  23. out = tmp_path / "joe_biden.ttl"
  24. out.write_text(turtle, encoding="utf-8")
  25. assert out.exists()
  26. assert 'atlas:canonicalLabel "Joe Biden"' in out.read_text(encoding="utf-8")