semantics
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# [DEF:TestMigrationEngine:Module]
|
||||
# #region TestMigrationEngine [C:2] [TYPE Module]
|
||||
#
|
||||
# @PURPOSE: Unit tests for MigrationEngine's cross-filter patching algorithms.
|
||||
# @LAYER: Domain
|
||||
# @RELATION: VERIFIES -> [src.core.migration_engine:Module]
|
||||
# @LAYER Domain
|
||||
# @RELATION BINDS_TO -> [MigrationEngine]
|
||||
#
|
||||
import json
|
||||
import os
|
||||
@@ -23,8 +23,8 @@ from src.core.migration_engine import MigrationEngine
|
||||
# --- Fixtures ---
|
||||
|
||||
|
||||
# [DEF:MockMappingService:Class]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region MockMappingService [C:2] [TYPE Class]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Deterministic mapping service double for native filter ID remapping scenarios.
|
||||
# @INVARIANT: Returns mappings only for requested UUID keys present in seeded map.
|
||||
class MockMappingService:
|
||||
@@ -38,15 +38,15 @@ class MockMappingService:
|
||||
result = {}
|
||||
for uuid in uuids:
|
||||
if uuid in self.mappings:
|
||||
result[uuid] = self.mappings[uuid]
|
||||
result[EXT:Python:uuid] = self.mappings[EXT:Python:uuid]
|
||||
return result
|
||||
|
||||
|
||||
# [/DEF:MockMappingService:Class]
|
||||
# #endregion MockMappingService
|
||||
|
||||
|
||||
# [DEF:_write_dashboard_yaml:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region _write_dashboard_yaml [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Serialize dashboard metadata into YAML fixture with json_metadata payload for patch tests.
|
||||
def _write_dashboard_yaml(dir_path: Path, metadata: dict) -> Path:
|
||||
"""Helper: writes a dashboard YAML file with json_metadata."""
|
||||
@@ -58,11 +58,11 @@ def _write_dashboard_yaml(dir_path: Path, metadata: dict) -> Path:
|
||||
|
||||
# --- _patch_dashboard_metadata tests ---
|
||||
|
||||
# [/DEF:_write_dashboard_yaml:Function]
|
||||
# #endregion _write_dashboard_yaml
|
||||
|
||||
|
||||
# [DEF:test_patch_dashboard_metadata_replaces_chart_ids:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_patch_dashboard_metadata_replaces_chart_ids [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Verify native filter target chartId values are remapped via mapping service results.
|
||||
def test_patch_dashboard_metadata_replaces_chart_ids():
|
||||
"""Verifies that chartId values are replaced using the mapping service."""
|
||||
@@ -85,11 +85,11 @@ def test_patch_dashboard_metadata_replaces_chart_ids():
|
||||
)
|
||||
|
||||
|
||||
# [/DEF:test_patch_dashboard_metadata_replaces_chart_ids:Function]
|
||||
# #endregion test_patch_dashboard_metadata_replaces_chart_ids
|
||||
|
||||
|
||||
# [DEF:test_patch_dashboard_metadata_replaces_dataset_ids:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_patch_dashboard_metadata_replaces_dataset_ids [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Verify native filter target datasetId values are remapped via mapping service results.
|
||||
def test_patch_dashboard_metadata_replaces_dataset_ids():
|
||||
"""Verifies that datasetId values are replaced using the mapping service."""
|
||||
@@ -113,11 +113,11 @@ def test_patch_dashboard_metadata_replaces_dataset_ids():
|
||||
)
|
||||
|
||||
|
||||
# [/DEF:test_patch_dashboard_metadata_replaces_dataset_ids:Function]
|
||||
# #endregion test_patch_dashboard_metadata_replaces_dataset_ids
|
||||
|
||||
|
||||
# [DEF:test_patch_dashboard_metadata_skips_when_no_metadata:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_patch_dashboard_metadata_skips_when_no_metadata [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Ensure dashboard files without json_metadata are left unchanged by metadata patching.
|
||||
def test_patch_dashboard_metadata_skips_when_no_metadata():
|
||||
"""Verifies early return when json_metadata key is absent."""
|
||||
@@ -136,11 +136,11 @@ def test_patch_dashboard_metadata_skips_when_no_metadata():
|
||||
assert "json_metadata" not in data
|
||||
|
||||
|
||||
# [/DEF:test_patch_dashboard_metadata_skips_when_no_metadata:Function]
|
||||
# #endregion test_patch_dashboard_metadata_skips_when_no_metadata
|
||||
|
||||
|
||||
# [DEF:test_patch_dashboard_metadata_handles_missing_targets:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_patch_dashboard_metadata_handles_missing_targets [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Verify patching updates mapped targets while preserving unmapped native filter IDs.
|
||||
def test_patch_dashboard_metadata_handles_missing_targets():
|
||||
"""When some source IDs have no target mapping, patches what it can and leaves the rest."""
|
||||
@@ -170,11 +170,11 @@ def test_patch_dashboard_metadata_handles_missing_targets():
|
||||
|
||||
# --- _extract_chart_uuids_from_archive tests ---
|
||||
|
||||
# [/DEF:test_patch_dashboard_metadata_handles_missing_targets:Function]
|
||||
# #endregion test_patch_dashboard_metadata_handles_missing_targets
|
||||
|
||||
|
||||
# [DEF:test_extract_chart_uuids_from_archive:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_extract_chart_uuids_from_archive [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Verify chart archive scan returns complete local chart id-to-uuid mapping.
|
||||
def test_extract_chart_uuids_from_archive():
|
||||
"""Verifies that chart YAML files are parsed for id->uuid mappings."""
|
||||
@@ -199,11 +199,11 @@ def test_extract_chart_uuids_from_archive():
|
||||
|
||||
# --- _transform_yaml tests ---
|
||||
|
||||
# [/DEF:test_extract_chart_uuids_from_archive:Function]
|
||||
# #endregion test_extract_chart_uuids_from_archive
|
||||
|
||||
|
||||
# [DEF:test_transform_yaml_replaces_database_uuid:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_transform_yaml_replaces_database_uuid [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Ensure dataset YAML database_uuid fields are replaced when source UUID mapping exists.
|
||||
def test_transform_yaml_replaces_database_uuid():
|
||||
"""Verifies that database_uuid in a dataset YAML is replaced."""
|
||||
@@ -222,11 +222,11 @@ def test_transform_yaml_replaces_database_uuid():
|
||||
assert data["table_name"] == "my_table"
|
||||
|
||||
|
||||
# [/DEF:test_transform_yaml_replaces_database_uuid:Function]
|
||||
# #endregion test_transform_yaml_replaces_database_uuid
|
||||
|
||||
|
||||
# [DEF:test_transform_yaml_ignores_unmapped_uuid:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_transform_yaml_ignores_unmapped_uuid [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Ensure transform_yaml leaves dataset files untouched when database_uuid is not mapped.
|
||||
def test_transform_yaml_ignores_unmapped_uuid():
|
||||
"""Verifies no changes when UUID is not in the mapping."""
|
||||
@@ -247,11 +247,11 @@ def test_transform_yaml_ignores_unmapped_uuid():
|
||||
|
||||
# --- [NEW] transform_zip E2E tests ---
|
||||
|
||||
# [/DEF:test_transform_yaml_ignores_unmapped_uuid:Function]
|
||||
# #endregion test_transform_yaml_ignores_unmapped_uuid
|
||||
|
||||
|
||||
# [DEF:test_transform_zip_end_to_end:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_transform_zip_end_to_end [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Validate full ZIP transform pipeline remaps datasets and dashboard cross-filter chart IDs.
|
||||
def test_transform_zip_end_to_end():
|
||||
"""Verifies full orchestration: extraction, transformation, patching, and re-packaging."""
|
||||
@@ -328,11 +328,11 @@ def test_transform_zip_end_to_end():
|
||||
)
|
||||
|
||||
|
||||
# [/DEF:test_transform_zip_end_to_end:Function]
|
||||
# #endregion test_transform_zip_end_to_end
|
||||
|
||||
|
||||
# [DEF:test_transform_zip_invalid_path:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_transform_zip_invalid_path [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Verify transform_zip returns False when source archive path does not exist.
|
||||
def test_transform_zip_invalid_path():
|
||||
"""@PRE: Verify behavior (False) on invalid ZIP path."""
|
||||
@@ -341,11 +341,11 @@ def test_transform_zip_invalid_path():
|
||||
assert success is False
|
||||
|
||||
|
||||
# [/DEF:test_transform_zip_invalid_path:Function]
|
||||
# #endregion test_transform_zip_invalid_path
|
||||
|
||||
|
||||
# [DEF:test_transform_yaml_nonexistent_file:Function]
|
||||
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
|
||||
# #region test_transform_yaml_nonexistent_file [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO -> [TestMigrationEngine]
|
||||
# @PURPOSE: Verify transform_yaml raises FileNotFoundError for missing YAML source files.
|
||||
def test_transform_yaml_nonexistent_file():
|
||||
"""@PRE: Verify behavior on non-existent YAML file."""
|
||||
@@ -356,5 +356,5 @@ def test_transform_yaml_nonexistent_file():
|
||||
engine._transform_yaml(Path("non_existent.yaml"), {})
|
||||
|
||||
|
||||
# [/DEF:test_transform_yaml_nonexistent_file:Function]
|
||||
# [/DEF:TestMigrationEngine:Module]
|
||||
# #endregion test_transform_yaml_nonexistent_file
|
||||
# #endregion TestMigrationEngine
|
||||
|
||||
Reference in New Issue
Block a user