fix: finalize semantic repair and test updates
This commit is contained in:
@@ -22,6 +22,7 @@ from src.core.migration.archive_parser import MigrationArchiveParser
|
||||
|
||||
# [DEF:test_extract_objects_from_zip_collects_all_types:Function]
|
||||
# @RELATION: BINDS_TO -> TestArchiveParser
|
||||
# @PURPOSE: Verify archive parser collects dashboard/chart/dataset YAML objects into typed buckets.
|
||||
def test_extract_objects_from_zip_collects_all_types():
|
||||
parser = MigrationArchiveParser()
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
@@ -33,11 +34,19 @@ def test_extract_objects_from_zip_collects_all_types():
|
||||
(src_dir / "datasets").mkdir(parents=True)
|
||||
|
||||
with open(src_dir / "dashboards" / "dash.yaml", "w") as file_obj:
|
||||
yaml.dump({"uuid": "dash-u1", "dashboard_title": "D1", "json_metadata": "{}"}, file_obj)
|
||||
yaml.dump(
|
||||
{"uuid": "dash-u1", "dashboard_title": "D1", "json_metadata": "{}"},
|
||||
file_obj,
|
||||
)
|
||||
with open(src_dir / "charts" / "chart.yaml", "w") as file_obj:
|
||||
yaml.dump({"uuid": "chart-u1", "slice_name": "C1", "viz_type": "bar"}, file_obj)
|
||||
yaml.dump(
|
||||
{"uuid": "chart-u1", "slice_name": "C1", "viz_type": "bar"}, file_obj
|
||||
)
|
||||
with open(src_dir / "datasets" / "dataset.yaml", "w") as file_obj:
|
||||
yaml.dump({"uuid": "ds-u1", "table_name": "orders", "database_uuid": "db-u1"}, file_obj)
|
||||
yaml.dump(
|
||||
{"uuid": "ds-u1", "table_name": "orders", "database_uuid": "db-u1"},
|
||||
file_obj,
|
||||
)
|
||||
|
||||
with zipfile.ZipFile(zip_path, "w") as zip_obj:
|
||||
for root, _, files in os.walk(src_dir):
|
||||
@@ -61,5 +70,5 @@ def test_extract_objects_from_zip_collects_all_types():
|
||||
raise AssertionError("dataset uuid mismatch")
|
||||
|
||||
|
||||
# [/DEF:TestArchiveParser:Module]
|
||||
# [/DEF:test_extract_objects_from_zip_collects_all_types:Function]
|
||||
# [/DEF:TestArchiveParser:Module]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# @COMPLEXITY: 3
|
||||
# @PURPOSE: Unit tests for MigrationDryRunService diff and risk computation contracts.
|
||||
# @LAYER: Domain
|
||||
# @RELATION: VERIFIES -> backend.src.core.migration.dry_run_orchestrator
|
||||
# @RELATION: VERIFIES -> [MigrationDryRunOrchestratorModule]
|
||||
#
|
||||
import json
|
||||
import sys
|
||||
@@ -24,16 +24,21 @@ from src.models.mapping import Base
|
||||
|
||||
|
||||
# [DEF:_load_fixture:Function]
|
||||
# @RELATION: BINDS_TO -> TestDryRunOrchestrator
|
||||
# @RELATION: BINDS_TO -> [TestDryRunOrchestrator]
|
||||
# @PURPOSE: Load canonical migration dry-run fixture payload used by deterministic orchestration assertions.
|
||||
def _load_fixture() -> dict:
|
||||
fixture_path = Path(__file__).parents[2] / "fixtures" / "migration_dry_run_fixture.json"
|
||||
fixture_path = (
|
||||
Path(__file__).parents[2] / "fixtures" / "migration_dry_run_fixture.json"
|
||||
)
|
||||
return json.loads(fixture_path.read_text())
|
||||
|
||||
|
||||
# [/DEF:_load_fixture:Function]
|
||||
|
||||
|
||||
# [DEF:_make_session:Function]
|
||||
# @RELATION: BINDS_TO -> TestDryRunOrchestrator
|
||||
# @RELATION: BINDS_TO -> [TestDryRunOrchestrator]
|
||||
# @PURPOSE: Build isolated in-memory SQLAlchemy session for dry-run service tests.
|
||||
def _make_session():
|
||||
engine = create_engine(
|
||||
"sqlite:///:memory:",
|
||||
@@ -47,8 +52,10 @@ def _make_session():
|
||||
|
||||
# [/DEF:_make_session:Function]
|
||||
|
||||
|
||||
# [DEF:test_migration_dry_run_service_builds_diff_and_risk:Function]
|
||||
# @RELATION: BINDS_TO -> TestDryRunOrchestrator
|
||||
# @RELATION: BINDS_TO -> [TestDryRunOrchestrator]
|
||||
# @PURPOSE: Verify dry-run orchestration returns stable diff summary and required risk codes.
|
||||
def test_migration_dry_run_service_builds_diff_and_risk():
|
||||
# @TEST_CONTRACT: dry_run_result_contract -> {
|
||||
# required_fields: {diff: object, summary: object, risk: object},
|
||||
@@ -68,7 +75,9 @@ def test_migration_dry_run_service_builds_diff_and_risk():
|
||||
)
|
||||
|
||||
source_client = MagicMock()
|
||||
source_client.get_dashboards_summary.return_value = fixture["source_dashboard_summary"]
|
||||
source_client.get_dashboards_summary.return_value = fixture[
|
||||
"source_dashboard_summary"
|
||||
]
|
||||
source_client.export_dashboard.return_value = (b"PK\x03\x04", "source.zip")
|
||||
|
||||
target_client = MagicMock()
|
||||
@@ -117,5 +126,5 @@ def test_migration_dry_run_service_builds_diff_and_risk():
|
||||
raise AssertionError("breaking_reference risk is not detected")
|
||||
|
||||
|
||||
# [/DEF:TestDryRunOrchestrator:Module]
|
||||
# [/DEF:test_migration_dry_run_service_builds_diff_and_risk:Function]
|
||||
# [/DEF:TestDryRunOrchestrator:Module]
|
||||
|
||||
Reference in New Issue
Block a user