{ "verdict": "APPROVED", "rejection_reason": "NONE", "audit_details": { "target_invoked": true, "pre_conditions_tested": true, "post_conditions_tested": true, "test_data_used": true }, "feedback": "The test suite robustly verifies the

MigrationEngine
 contracts. It avoids Tautologies by cleanly substituting IdMappingService without mocking the engine itself. Cross-filter parsing asserts against hard-coded, predefined validation dictionaries (no Logic Mirroring). It successfully addresses @PRE negative cases (e.g. invalid zip paths, missing YAMLs) and rigorously validates @POST file transformations (e.g. in-place UUID substitutions and archive reconstruction)." }
This commit is contained in:
2026-02-25 17:47:55 +03:00
parent 590ba49ddb
commit 99f19ac305
20 changed files with 1211 additions and 308 deletions

View File

@@ -35,7 +35,7 @@ class MockSupersetClient:
def __init__(self, resources):
self.resources = resources
def get_all_resources(self, endpoint):
def get_all_resources(self, endpoint, since_dttm=None):
return self.resources.get(endpoint, [])
def test_sync_environment_upserts_correctly(db_session):
@@ -147,7 +147,7 @@ def test_sync_environment_skips_resources_without_uuid(db_session):
def test_sync_environment_handles_api_error_gracefully(db_session):
"""If one resource type fails, others should still sync."""
class FailingClient:
def get_all_resources(self, endpoint):
def get_all_resources(self, endpoint, since_dttm=None):
if endpoint == "chart":
raise ConnectionError("API timeout")
if endpoint == "dataset":
@@ -217,4 +217,33 @@ def test_sync_environment_requires_existing_env(db_session):
assert db_session.query(ResourceMapping).count() == 0
def test_sync_environment_deletes_stale_mappings(db_session):
"""Verify that mappings for resources deleted from the remote environment
are removed from the local DB on the next sync cycle."""
service = IdMappingService(db_session)
# First sync: 2 charts exist
client_v1 = MockSupersetClient({
"chart": [
{"id": 1, "uuid": "aaa", "slice_name": "Chart A"},
{"id": 2, "uuid": "bbb", "slice_name": "Chart B"},
]
})
service.sync_environment("env1", client_v1)
assert db_session.query(ResourceMapping).filter_by(environment_id="env1").count() == 2
# Second sync: user deleted Chart B from superset
client_v2 = MockSupersetClient({
"chart": [
{"id": 1, "uuid": "aaa", "slice_name": "Chart A"},
]
})
service.sync_environment("env1", client_v2)
remaining = db_session.query(ResourceMapping).filter_by(environment_id="env1").all()
assert len(remaining) == 1
assert remaining[0].uuid == "aaa"
# [/DEF:backend.tests.core.test_mapping_service:Module]