8af9584d09
CI / detect-changes (pull_request) Failing after 5s
CI / branch-name (pull_request) Successful in 2s
CI / guardrail-integrity (pull_request) Failing after 4s
CI / secret-scan (pull_request) Failing after 4s
CI / dep-audit (pull_request) Failing after 2s
CI / sbom-scan (pull_request) Failing after 2s
CI / build-sha-integrity (pull_request) Failing after 3s
CI / validate-canonical-controls (pull_request) Failing after 3s
CI / loc-budget (pull_request) Has been skipped
CI / go-lint (pull_request) Has been skipped
CI / python-lint (pull_request) Has been skipped
CI / nodejs-lint (pull_request) Has been skipped
CI / nodejs-build (pull_request) Has been skipped
CI / test-go (pull_request) Has been skipped
CI / iace-gt-coverage (pull_request) Has been skipped
CI / test-python-backend (pull_request) Has been skipped
CI / test-python-document-crawler (pull_request) Has been skipped
CI / test-python-dsms-gateway (pull_request) Has been skipped
Replace the reconstructed test_dse_agent.py with the canonical version and add the companion unit tests (classification_gate, embedding_recall) covering the recovered v3 modules. Include the curated DSE criteria backup + changelog (legal-note rationale per control), the v1 validation writeup, and the multi-company DSE ground-truth fulltexts (elli/eto/mercedes/safetykon) used for threshold calibration. 18 DSE tests green offline (DB/embedding/LLM stubbed). dev-only, no deploy. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
"""Tests fuer das DSE-Applicability-Gate (_classification_gate).
|
|
|
|
Deckt die reine Split-Logik (apply_gate) und das defensive Verhalten von
|
|
load_dse_gate ohne DB ab. Die DB-Abfrage selbst ist I/O und wird hier nicht
|
|
gegen eine echte DB getestet (defensiver Pfad: kein DSN -> leeres Dict)."""
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from compliance.services.specialist_agents.dse._classification_gate import (
|
|
apply_gate,
|
|
load_dse_gate,
|
|
)
|
|
|
|
|
|
def test_apply_gate_splits_findings_and_organizational():
|
|
controls = [
|
|
{"control_id": "AUTH-2051-A02", "title": "Speicherdauer nennen"},
|
|
{"control_id": "AUTH-2049-A01", "title": "VVT fuehren"},
|
|
]
|
|
gate = {
|
|
"AUTH-2049-A01": {
|
|
"obligation_type": "EVIDENCE",
|
|
"check_intent": "DIRECT_EVIDENCE",
|
|
"applicable_artifacts": ["VVT", "AUDIT"],
|
|
"reference_allowed": "NO",
|
|
}
|
|
}
|
|
kept, organizational = apply_gate(controls, gate)
|
|
assert [c["control_id"] for c in kept] == ["AUTH-2051-A02"]
|
|
assert len(organizational) == 1
|
|
org = organizational[0]
|
|
assert org["control_id"] == "AUTH-2049-A01"
|
|
assert org["title"] == "VVT fuehren"
|
|
assert org["applicable_artifacts"] == ["VVT", "AUDIT"]
|
|
assert org["check_intent"] == "DIRECT_EVIDENCE"
|
|
|
|
|
|
def test_apply_gate_empty_gate_keeps_all():
|
|
controls = [{"control_id": "X-1"}, {"control_id": "X-2"}]
|
|
kept, organizational = apply_gate(controls, {})
|
|
assert len(kept) == 2
|
|
assert organizational == []
|
|
|
|
|
|
def test_load_dse_gate_without_dsn_is_defensive():
|
|
"""Kein DSN + keine Env -> leeres Dict (kein Filter), kein Fehler."""
|
|
saved = (
|
|
os.environ.pop("DATABASE_URL", None),
|
|
os.environ.pop("COMPLIANCE_DATABASE_URL", None),
|
|
)
|
|
try:
|
|
result = asyncio.run(load_dse_gate(""))
|
|
assert result == {}
|
|
finally:
|
|
if saved[0] is not None:
|
|
os.environ["DATABASE_URL"] = saved[0]
|
|
if saved[1] is not None:
|
|
os.environ["COMPLIANCE_DATABASE_URL"] = saved[1]
|