from pathlib import Path ROOT = Path(__file__).resolve().parents[2] def test_ontology_migration_is_additive_and_versioned(): source = (ROOT / "migrations/versions/20260722_110_data_research_ontology.py").read_text(encoding="utf-8") for table in ( "ontologies", "ontology_versions", "ontology_domain_links", "ontology_change_sets", "ontology_publish_runs", ): assert f"public.{table}" in source assert 'down_revision = "20260722_105"' in source assert "active_version_uid" in source assert "content_hash" in source assert "UNIQUE (ontology_uid, version)" in source def test_graph_document_has_governance_sections(): from app.core.data_research.ontology.models import GraphDocument graph = GraphDocument.from_dict({}) assert graph.to_dict() == { "classes": [], "properties": [], "relations": [], "constraints": [], "domain_links": [], "element_mappings": [], }