fix: finalize semantic repair and test updates
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
# @SEMANTICS: clean-release, policy-resolution, trusted-snapshots, contracts
|
||||
# @PURPOSE: Verify trusted policy snapshot resolution contract and error guards.
|
||||
# @LAYER: Tests
|
||||
# @RELATION: DEPENDS_ON -> backend.src.services.clean_release.policy_resolution_service
|
||||
# @RELATION: DEPENDS_ON -> backend.src.services.clean_release.repository
|
||||
# @RELATION: DEPENDS_ON -> backend.src.services.clean_release.exceptions
|
||||
# @RELATION: DEPENDS_ON -> [policy_resolution_service]
|
||||
# @RELATION: DEPENDS_ON -> [repository]
|
||||
# @RELATION: DEPENDS_ON -> [clean_release_exceptions]
|
||||
# @INVARIANT: Resolution uses only ConfigManager active IDs and rejects runtime override attempts.
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -16,25 +16,33 @@ import pytest
|
||||
|
||||
from src.models.clean_release import CleanPolicySnapshot, SourceRegistrySnapshot
|
||||
from src.services.clean_release.exceptions import PolicyResolutionError
|
||||
from src.services.clean_release.policy_resolution_service import resolve_trusted_policy_snapshots
|
||||
from src.services.clean_release.policy_resolution_service import (
|
||||
resolve_trusted_policy_snapshots,
|
||||
)
|
||||
from src.services.clean_release.repository import CleanReleaseRepository
|
||||
|
||||
|
||||
# [DEF:_config_manager:Function]
|
||||
# @RELATION: BINDS_TO -> TestPolicyResolutionService
|
||||
# @RELATION: BINDS_TO -> [TestPolicyResolutionService]
|
||||
# @COMPLEXITY: 1
|
||||
# @PURPOSE: Build deterministic ConfigManager-like stub for tests.
|
||||
# @INVARIANT: Only settings.clean_release.active_policy_id and active_registry_id are populated; any other settings field access raises AttributeError.
|
||||
# @PRE: policy_id and registry_id may be None or non-empty strings.
|
||||
# @POST: Returns object exposing get_config().settings.clean_release active IDs.
|
||||
def _config_manager(policy_id, registry_id):
|
||||
clean_release = SimpleNamespace(active_policy_id=policy_id, active_registry_id=registry_id)
|
||||
clean_release = SimpleNamespace(
|
||||
active_policy_id=policy_id, active_registry_id=registry_id
|
||||
)
|
||||
settings = SimpleNamespace(clean_release=clean_release)
|
||||
config = SimpleNamespace(settings=settings)
|
||||
return SimpleNamespace(get_config=lambda: config)
|
||||
|
||||
|
||||
# [/DEF:_config_manager:Function]
|
||||
|
||||
|
||||
# [DEF:test_resolve_trusted_policy_snapshots_missing_profile:Function]
|
||||
# @RELATION: BINDS_TO -> TestPolicyResolutionService
|
||||
# @RELATION: BINDS_TO -> [TestPolicyResolutionService]
|
||||
# @PURPOSE: Ensure resolution fails when trusted profile is not configured.
|
||||
# @PRE: active_policy_id is None.
|
||||
# @POST: Raises PolicyResolutionError with missing trusted profile reason.
|
||||
@@ -47,11 +55,13 @@ def test_resolve_trusted_policy_snapshots_missing_profile():
|
||||
config_manager=config_manager,
|
||||
repository=repository,
|
||||
)
|
||||
|
||||
|
||||
# [/DEF:test_resolve_trusted_policy_snapshots_missing_profile:Function]
|
||||
|
||||
|
||||
# [DEF:test_resolve_trusted_policy_snapshots_missing_registry:Function]
|
||||
# @RELATION: BINDS_TO -> TestPolicyResolutionService
|
||||
# @RELATION: BINDS_TO -> [TestPolicyResolutionService]
|
||||
# @PURPOSE: Ensure resolution fails when trusted registry is not configured.
|
||||
# @PRE: active_registry_id is None and active_policy_id is set.
|
||||
# @POST: Raises PolicyResolutionError with missing trusted registry reason.
|
||||
@@ -64,11 +74,13 @@ def test_resolve_trusted_policy_snapshots_missing_registry():
|
||||
config_manager=config_manager,
|
||||
repository=repository,
|
||||
)
|
||||
|
||||
|
||||
# [/DEF:test_resolve_trusted_policy_snapshots_missing_registry:Function]
|
||||
|
||||
|
||||
# [DEF:test_resolve_trusted_policy_snapshots_rejects_override_attempt:Function]
|
||||
# @RELATION: BINDS_TO -> TestPolicyResolutionService
|
||||
# @RELATION: BINDS_TO -> [TestPolicyResolutionService]
|
||||
# @PURPOSE: Ensure runtime override attempt is rejected even if snapshots exist.
|
||||
# @PRE: valid trusted snapshots exist in repository and override is provided.
|
||||
# @POST: Raises PolicyResolutionError with override forbidden reason.
|
||||
@@ -104,6 +116,8 @@ def test_resolve_trusted_policy_snapshots_rejects_override_attempt():
|
||||
repository=repository,
|
||||
policy_id_override="policy-override",
|
||||
)
|
||||
|
||||
|
||||
# [/DEF:test_resolve_trusted_policy_snapshots_rejects_override_attempt:Function]
|
||||
|
||||
# [/DEF:TestPolicyResolutionService:Module]
|
||||
|
||||
Reference in New Issue
Block a user