test_phase2_wp01_migration_contract.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from pathlib import Path
  2. ROOT = Path(__file__).resolve().parents[1]
  3. def test_domain_template_migration_is_additive_versioned_and_auditable():
  4. migration = (
  5. ROOT
  6. / "migrations"
  7. / "versions"
  8. / "20260730_370_governance_domain_templates.py"
  9. ).read_text(encoding="utf-8")
  10. assert 'revision = "20260730_370"' in migration
  11. assert 'down_revision = "20260730_360"' in migration
  12. for table in (
  13. "governance_domain_templates",
  14. "governance_domain_template_versions",
  15. "governance_object_types",
  16. "governance_domain_template_imports",
  17. ):
  18. assert f"CREATE TABLE public.{table}" in migration
  19. assert "definition JSONB NOT NULL" in migration
  20. assert "source_identity_fields JSONB NOT NULL" in migration
  21. assert "before_state JSONB" in migration
  22. assert "after_state JSONB NOT NULL" in migration
  23. assert "operation IN ('import','rollback')" in migration
  24. assert "DROP TABLE" not in migration.upper()
  25. def test_release_copy_will_include_domain_template_runtime():
  26. for relative in (
  27. "core/governance/domain_templates.py",
  28. "core/governance/domain_template_repository.py",
  29. "api/meta_data/domain_templates.py",
  30. "models/governance_template.py",
  31. ):
  32. assert (ROOT / "app" / relative).read_bytes() == (
  33. ROOT / "deployment" / "app" / relative
  34. ).read_bytes()