test_ontology_schema.py 1006 B

12345678910111213141516171819202122232425262728293031323334
  1. from pathlib import Path
  2. ROOT = Path(__file__).resolve().parents[2]
  3. def test_ontology_migration_is_additive_and_versioned():
  4. source = (ROOT / "migrations/versions/20260722_110_data_research_ontology.py").read_text(encoding="utf-8")
  5. for table in (
  6. "ontologies",
  7. "ontology_versions",
  8. "ontology_domain_links",
  9. "ontology_change_sets",
  10. "ontology_publish_runs",
  11. ):
  12. assert f"public.{table}" in source
  13. assert 'down_revision = "20260722_105"' in source
  14. assert "active_version_uid" in source
  15. assert "content_hash" in source
  16. assert "UNIQUE (ontology_uid, version)" in source
  17. def test_graph_document_has_governance_sections():
  18. from app.core.data_research.ontology.models import GraphDocument
  19. graph = GraphDocument.from_dict({})
  20. assert graph.to_dict() == {
  21. "classes": [],
  22. "properties": [],
  23. "relations": [],
  24. "constraints": [],
  25. "domain_links": [],
  26. "element_mappings": [],
  27. }