104 lines
3.4 KiB
Python
104 lines
3.4 KiB
Python
from pathlib import Path
|
|
|
|
from scripts.finalize_mvp_pilot import apply_gate4_closure, parse_open_defect_counts
|
|
from scripts.uat_manual_prepare import render_session_protocol
|
|
|
|
|
|
def test_render_session_protocol_prefills_safe_fields():
|
|
template = "\n".join(
|
|
[
|
|
"# UAT Session Protocol",
|
|
"",
|
|
"- Session ID:",
|
|
"- Date:",
|
|
"- Environment URL:",
|
|
"- Build/version:",
|
|
"- Deployment date:",
|
|
"- Cluster/namespace:",
|
|
"",
|
|
"- Operators:",
|
|
"- Supervisor:",
|
|
"- Analyst:",
|
|
"- Admin:",
|
|
"- Business owner:",
|
|
"- IT owner:",
|
|
"",
|
|
"- [ ] Preflight report attached (`docs/uat/evidence/preflight_*.md`)",
|
|
"- [ ] Defect log prepared from `docs/uat/defect-log-template.csv`",
|
|
]
|
|
)
|
|
result = render_session_protocol(
|
|
template,
|
|
session_id="UAT-MANUAL-001",
|
|
environment_url="http://pilot:8080",
|
|
build_version="v1.0.0-mvp",
|
|
deployment_date="2026-02-27",
|
|
cluster_namespace="pilot/ns",
|
|
participants={
|
|
"operators": "Ops Team",
|
|
"supervisor": "Sup User",
|
|
"analyst": "Analyst User",
|
|
"admin": "Admin User",
|
|
"business_owner": "Biz Owner",
|
|
"it_owner": "IT Owner",
|
|
},
|
|
preflight_name="preflight_latest.md",
|
|
defect_log_name="defect-log.csv",
|
|
)
|
|
|
|
assert "- Session ID: UAT-MANUAL-001" in result
|
|
assert "- Environment URL: http://pilot:8080" in result
|
|
assert "- Build/version: v1.0.0-mvp" in result
|
|
assert "- Business owner: Biz Owner" in result
|
|
assert "- [x] Preflight report attached (`attachments/preflight_latest.md`)" in result
|
|
assert "- [x] Defect log prepared from `defect-log.csv`" in result
|
|
|
|
|
|
def test_parse_open_defect_counts_counts_only_non_closed(tmp_path: Path):
|
|
defect_log = tmp_path / "defect-log.csv"
|
|
defect_log.write_text(
|
|
"\n".join(
|
|
[
|
|
"defect_id,severity,status,scenario,summary",
|
|
"UAT-001,P1,Open,S1,broken login",
|
|
"UAT-002,P1,Closed,S1,closed login",
|
|
"UAT-003,P2,Resolved,S2,resolved issue",
|
|
"UAT-004,P2,Open,S2,open issue",
|
|
"UAT-005,P3,Deferred,S3,deferred issue",
|
|
"UAT-006,P4,Open,S4,cosmetic issue",
|
|
]
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
counts = parse_open_defect_counts(defect_log)
|
|
|
|
assert counts == {"P1": 1, "P2": 1, "P3": 1, "P4": 1}
|
|
|
|
|
|
def test_apply_gate4_closure_marks_manual_items():
|
|
source = "\n".join(
|
|
[
|
|
"# Gate 4 Checklist (Pilot Hardening)",
|
|
"",
|
|
"- [ ] UAT signed with real operators/supervisors",
|
|
"- [ ] P1/P2 defects closed",
|
|
"",
|
|
"Notes:",
|
|
"- placeholder",
|
|
]
|
|
)
|
|
|
|
updated = apply_gate4_closure(
|
|
source,
|
|
session_id="UAT-MANUAL-001",
|
|
session_dir=Path("docs/uat/evidence/manual_UAT-MANUAL-001"),
|
|
acceptance="accepted_for_pilot_completion",
|
|
open_counts={"P1": 0, "P2": 0, "P3": 2, "P4": 1},
|
|
)
|
|
|
|
assert "- [x] UAT signed with real operators/supervisors" in updated
|
|
assert "- [x] P1/P2 defects closed" in updated
|
|
assert "Manual closure update:" in updated
|
|
assert "P1=0, P2=0, P3=2, P4=1" in updated
|