semantics
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# [DEF:TestMappingService:Module]
|
||||
# #region TestMappingService [C:2] [TYPE Module]
|
||||
#
|
||||
# @PURPOSE: Unit tests for the IdMappingService matching UUIDs to integer IDs.
|
||||
# @LAYER: Domain
|
||||
# @RELATION: VERIFIES ->[src.core.mapping_service.IdMappingService]
|
||||
# @LAYER Domain
|
||||
# @RELATION BINDS_TO ->[IdMappingService]
|
||||
#
|
||||
import sys
|
||||
from datetime import UTC, datetime
|
||||
@@ -40,8 +40,8 @@ class MockSupersetClient:
|
||||
return self.resources.get(endpoint, [])
|
||||
|
||||
|
||||
# [DEF:test_sync_environment_upserts_correctly:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_sync_environment_upserts_correctly [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_sync_environment_upserts_correctly(db_session):
|
||||
service = IdMappingService(db_session)
|
||||
mock_client = MockSupersetClient(
|
||||
@@ -67,11 +67,11 @@ def test_sync_environment_upserts_correctly(db_session):
|
||||
assert mapping.resource_name == "Test Chart"
|
||||
|
||||
|
||||
# [/DEF:test_sync_environment_upserts_correctly:Function]
|
||||
# #endregion test_sync_environment_upserts_correctly
|
||||
|
||||
|
||||
# [DEF:test_get_remote_id_returns_integer:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_get_remote_id_returns_integer [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_get_remote_id_returns_integer(db_session):
|
||||
service = IdMappingService(db_session)
|
||||
mapping = ResourceMapping(
|
||||
@@ -89,11 +89,11 @@ def test_get_remote_id_returns_integer(db_session):
|
||||
assert result == 99
|
||||
|
||||
|
||||
# [/DEF:test_get_remote_id_returns_integer:Function]
|
||||
# #endregion test_get_remote_id_returns_integer
|
||||
|
||||
|
||||
# [DEF:test_get_remote_ids_batch_returns_dict:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_get_remote_ids_batch_returns_dict [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_get_remote_ids_batch_returns_dict(db_session):
|
||||
service = IdMappingService(db_session)
|
||||
m1 = ResourceMapping(
|
||||
@@ -121,11 +121,11 @@ def test_get_remote_ids_batch_returns_dict(db_session):
|
||||
assert "uuid-missing" not in result
|
||||
|
||||
|
||||
# [/DEF:test_get_remote_ids_batch_returns_dict:Function]
|
||||
# #endregion test_get_remote_ids_batch_returns_dict
|
||||
|
||||
|
||||
# [DEF:test_sync_environment_updates_existing_mapping:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_sync_environment_updates_existing_mapping [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_sync_environment_updates_existing_mapping(db_session):
|
||||
"""Verify that sync_environment updates an existing mapping (upsert UPDATE path)."""
|
||||
from src.models.mapping import ResourceMapping
|
||||
@@ -168,11 +168,11 @@ def test_sync_environment_updates_existing_mapping(db_session):
|
||||
assert count == 1
|
||||
|
||||
|
||||
# [/DEF:test_sync_environment_updates_existing_mapping:Function]
|
||||
# #endregion test_sync_environment_updates_existing_mapping
|
||||
|
||||
|
||||
# [DEF:test_sync_environment_skips_resources_without_uuid:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_sync_environment_skips_resources_without_uuid [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_sync_environment_skips_resources_without_uuid(db_session):
|
||||
"""Resources missing uuid or having id=None should be silently skipped."""
|
||||
service = IdMappingService(db_session)
|
||||
@@ -200,11 +200,11 @@ def test_sync_environment_skips_resources_without_uuid(db_session):
|
||||
assert count == 0
|
||||
|
||||
|
||||
# [/DEF:test_sync_environment_skips_resources_without_uuid:Function]
|
||||
# #endregion test_sync_environment_skips_resources_without_uuid
|
||||
|
||||
|
||||
# [DEF:test_sync_environment_handles_api_error_gracefully:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_sync_environment_handles_api_error_gracefully [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_sync_environment_handles_api_error_gracefully(db_session):
|
||||
"""If one resource type fails, others should still sync."""
|
||||
|
||||
@@ -225,11 +225,11 @@ def test_sync_environment_handles_api_error_gracefully(db_session):
|
||||
assert mapping.resource_type == ResourceType.DATASET
|
||||
|
||||
|
||||
# [/DEF:test_sync_environment_handles_api_error_gracefully:Function]
|
||||
# #endregion test_sync_environment_handles_api_error_gracefully
|
||||
|
||||
|
||||
# [DEF:test_get_remote_id_returns_none_for_missing:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_get_remote_id_returns_none_for_missing [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_get_remote_id_returns_none_for_missing(db_session):
|
||||
"""get_remote_id should return None when no mapping exists."""
|
||||
service = IdMappingService(db_session)
|
||||
@@ -237,11 +237,11 @@ def test_get_remote_id_returns_none_for_missing(db_session):
|
||||
assert result is None
|
||||
|
||||
|
||||
# [/DEF:test_get_remote_id_returns_none_for_missing:Function]
|
||||
# #endregion test_get_remote_id_returns_none_for_missing
|
||||
|
||||
|
||||
# [DEF:test_get_remote_ids_batch_returns_empty_for_empty_input:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_get_remote_ids_batch_returns_empty_for_empty_input [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_get_remote_ids_batch_returns_empty_for_empty_input(db_session):
|
||||
"""get_remote_ids_batch should return {} for an empty list of UUIDs."""
|
||||
service = IdMappingService(db_session)
|
||||
@@ -249,11 +249,11 @@ def test_get_remote_ids_batch_returns_empty_for_empty_input(db_session):
|
||||
assert result == {}
|
||||
|
||||
|
||||
# [/DEF:test_get_remote_ids_batch_returns_empty_for_empty_input:Function]
|
||||
# #endregion test_get_remote_ids_batch_returns_empty_for_empty_input
|
||||
|
||||
|
||||
# [DEF:test_mapping_service_alignment_with_test_data:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_mapping_service_alignment_with_test_data [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_mapping_service_alignment_with_test_data(db_session):
|
||||
"""**@TEST_DATA**: Verifies that the service aligns with the resource_mapping_record contract."""
|
||||
# Contract: {'environment_id': 'prod-env-1', 'resource_type': 'chart', 'uuid': '123e4567-e89b-12d3-a456-426614174000', 'remote_integer_id': '42'}
|
||||
@@ -278,11 +278,11 @@ def test_mapping_service_alignment_with_test_data(db_session):
|
||||
assert result == 42
|
||||
|
||||
|
||||
# [/DEF:test_mapping_service_alignment_with_test_data:Function]
|
||||
# #endregion test_mapping_service_alignment_with_test_data
|
||||
|
||||
|
||||
# [DEF:test_sync_environment_requires_existing_env:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_sync_environment_requires_existing_env [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
def test_sync_environment_requires_existing_env(db_session):
|
||||
"""**@PRE**: Verify behavior when environment_id is invalid/missing in DB.
|
||||
Note: The current implementation doesn't strictly check for environment existencia in the DB
|
||||
@@ -301,11 +301,11 @@ def test_sync_environment_requires_existing_env(db_session):
|
||||
assert db_session.query(ResourceMapping).count() == 0
|
||||
|
||||
|
||||
# [/DEF:test_sync_environment_requires_existing_env:Function]
|
||||
# #endregion test_sync_environment_requires_existing_env
|
||||
|
||||
|
||||
# [DEF:test_sync_environment_deletes_stale_mappings:Function]
|
||||
# @RELATION: BINDS_TO ->[TestMappingService]
|
||||
# #region test_sync_environment_deletes_stale_mappings [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestMappingService]
|
||||
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."""
|
||||
@@ -340,5 +340,5 @@ def test_sync_environment_deletes_stale_mappings(db_session):
|
||||
assert remaining[0].uuid == "aaa"
|
||||
|
||||
|
||||
# [/DEF:test_sync_environment_deletes_stale_mappings:Function]
|
||||
# [/DEF:TestMappingService:Module]
|
||||
# #endregion test_sync_environment_deletes_stale_mappings
|
||||
# #endregion TestMappingService
|
||||
|
||||
Reference in New Issue
Block a user