Files
ss-tools/backend/tests/scripts/test_investigation_audit_trace.py
busya 323d732199 feat(investigations): add pinned baseline workspace and personal notifications
Add scoped verification and seven-day risk acceptance, a readable sixteen-metric baseline comparison, visual findings, and responsive case actions. Provide personal subscriptions and an in-app inbox with authorized target names.

Retain isolated Docker fixtures and browser audits for normal flows, access and CAS refusals, HTTP500, uncertain VLM results, polling and acceptance expiry. Verify scoped semantic contracts and record independent UX/UI scores of 4/5 and 4.1/5.
2026-10-05 23:00:05 +03:00

33 lines
1.4 KiB
Python

# #region Test.InvestigationAuditTrace [C:2] [TYPE Module]
# @TEST_INVARIANT Fresh empty CLI trace state gains a UUID before logging; inherited request trace is retained.
from uuid import UUID
from src.core.cot_logger import _trace_id, get_trace_id
from src.scripts.investigation_audit_entrypoint import load_source_environment
# #region Test.InvestigationAuditTrace.Empty [C:1] [TYPE Function]
def test_empty_job_context_gains_uuid_before_first_configuration_log(monkeypatch, tmp_path):
token = _trace_id.set('')
monkeypatch.setenv('INVESTIGATION_AUDIT', '1')
monkeypatch.setenv('INVESTIGATION_SECRET_FILE', str(tmp_path / 'missing.json'))
try:
load_source_environment()
assert UUID(get_trace_id()).version == 4
finally:
_trace_id.reset(token)
# #endregion Test.InvestigationAuditTrace.Empty
# #region Test.InvestigationAuditTrace.Inherited [C:1] [TYPE Function]
def test_existing_trace_survives_configuration_loading(monkeypatch, tmp_path):
token = _trace_id.set('a5c59088-d9fc-4253-9b75-a66330b2b36d')
monkeypatch.setenv('INVESTIGATION_AUDIT', '1')
monkeypatch.setenv('INVESTIGATION_SECRET_FILE', str(tmp_path / 'missing.json'))
try:
load_source_environment()
assert get_trace_id() == 'a5c59088-d9fc-4253-9b75-a66330b2b36d'
finally:
_trace_id.reset(token)
# #endregion Test.InvestigationAuditTrace.Inherited
# #endregion Test.InvestigationAuditTrace