"""ORCH-036 TC-15: the deploy-verdict parse contract is unchanged (AC-10). ``_parse_deploy_status`` reads ONLY the machine-readable ``deploy_status:`` YAML frontmatter (never prose). ORCH-036 produces the verdict differently (a deterministic finalizer instead of an LLM), but the parse contract that the gate relies on must remain bit-identical: SUCCESS -> (True, ...), FAILED -> (False, ...), no/!frontmatter -> (False, ...). """ import os os.environ.setdefault("ORCH_PLANE_API_TOKEN", "test-token") os.environ.setdefault("ORCH_GITEA_TOKEN", "test-token") from src.qg.checks import _parse_deploy_status # noqa: E402 from src.self_deploy import build_deploy_log # noqa: E402 def test_tc15_success_frontmatter_passes(): ok, reason = _parse_deploy_status("---\ndeploy_status: SUCCESS\n---\n\nbody") assert ok is True assert "SUCCESS" in reason def test_tc15_failed_frontmatter_fails(): ok, reason = _parse_deploy_status("---\ndeploy_status: FAILED\n---\n\nbody") assert ok is False assert "FAILED" in reason def test_tc15_no_frontmatter_fails(): ok, _ = _parse_deploy_status("just prose, deploy_status: SUCCESS in text but no frontmatter") assert ok is False def test_tc15_missing_field_fails(): ok, _ = _parse_deploy_status("---\nother_field: SUCCESS\n---\n") assert ok is False def test_tc15_prose_success_word_does_not_pass(): """Defensive: the word SUCCESS in prose must NOT satisfy the gate.""" ok, _ = _parse_deploy_status("# Deploy\n\nDeploy was a SUCCESS, hooray!\n") assert ok is False def test_tc15_finalizer_log_roundtrips_through_parser(): """The finalizer's rendered log must be readable by the EXISTING parser — SUCCESS passes, FAILED fails — proving the producer/consumer contract holds.""" ok_s, _ = _parse_deploy_status(build_deploy_log("ORCH-036", 0, "SUCCESS")) ok_f, _ = _parse_deploy_status(build_deploy_log("ORCH-036", 2, "FAILED")) assert ok_s is True assert ok_f is False