Systematic rename of all semantic anchors (#region, [DEF], @RELATION) across 1400+ files — backend Python, frontend Svelte/TS, specs, docs: - Flat anchors become Namespace.Module.Entity - @RELATION references updated to match new anchor paths - Zero business logic changes
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
# #region Test.DeploymentModel [C:2] [TYPE Module] [SEMANTICS test, deployment, model, validation]
|
|
# @BRIEF Python-level unit tests for DeploymentRecord model defaults.
|
|
# @RELATION BINDS_TO -> [Models.Deployment.DeploymentModels]
|
|
from src.models.deployment import DeploymentRecord
|
|
|
|
|
|
class TestDeploymentRecord:
|
|
"""DeploymentRecord model — Python-level attribute validation."""
|
|
|
|
def test_failed_status_with_error(self):
|
|
"""Status can be set to 'failed' with error message."""
|
|
record = DeploymentRecord(
|
|
repository_id="r-test",
|
|
environment_id="e-test",
|
|
commit_hash="a" * 40,
|
|
content_hash="b" * 64,
|
|
status="failed",
|
|
error_message="Deploy timed out",
|
|
)
|
|
assert record.status == "failed"
|
|
assert record.error_message == "Deploy timed out"
|
|
|
|
def test_resources_changed_json(self):
|
|
"""resources_changed accepts JSON dict at Python level."""
|
|
record = DeploymentRecord(
|
|
repository_id="r-test",
|
|
environment_id="e-test",
|
|
commit_hash="a" * 40,
|
|
content_hash="b" * 64,
|
|
resources_changed={"charts": ["uuid-1"], "dashboards": ["uuid-2"]},
|
|
)
|
|
assert record.resources_changed == {"charts": ["uuid-1"], "dashboards": ["uuid-2"]}
|
|
|
|
def test_deployed_by_tracks_user(self):
|
|
"""deployed_by stores the initiator username."""
|
|
record = DeploymentRecord(
|
|
repository_id="r-test",
|
|
environment_id="e-test",
|
|
commit_hash="a" * 40,
|
|
content_hash="b" * 64,
|
|
deployed_by="analyst@company.com",
|
|
)
|
|
assert record.deployed_by == "analyst@company.com"
|
|
|
|
def test_content_hash_length(self):
|
|
"""content_hash is SHA256 = 64 chars."""
|
|
record = DeploymentRecord(
|
|
repository_id="r-test",
|
|
environment_id="e-test",
|
|
commit_hash="a" * 40,
|
|
content_hash="c" * 64,
|
|
)
|
|
assert len(record.content_hash) == 64
|
|
|
|
def test_commit_hash_length(self):
|
|
"""commit_hash is git SHA = 40 chars."""
|
|
record = DeploymentRecord(
|
|
repository_id="r-test",
|
|
environment_id="e-test",
|
|
commit_hash="d" * 40,
|
|
content_hash="e" * 64,
|
|
)
|
|
assert len(record.commit_hash) == 40
|
|
|
|
|
|
# #endregion Test.DeploymentModel
|