FORGE-F016 Require authoritative application delivery evidence
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
"""Disposable evidence decisions for application-delivery skill exercises.
|
||||
|
||||
This is a model of the documented gates, not an application or a skill parser.
|
||||
The fixtures make the expected decisions observable without requiring Docker,
|
||||
a provider, or a particular web framework.
|
||||
"""
|
||||
|
||||
import copy
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def decision(facts, target):
|
||||
"""Return the first missing gate, or the requested outcome."""
|
||||
if facts["kind"] == "prototype":
|
||||
if target == "prototype_complete" and facts["prototype_approved"] and facts["prototype_delivered"]:
|
||||
return "prototype_complete"
|
||||
return "prototype_only"
|
||||
|
||||
destination = facts["destination"]
|
||||
required = ("frontend", "routing", "route", "screen", "navigation",
|
||||
"auth", "backend", "data", "environment", "conventions",
|
||||
"design", "baseline", "acceptance")
|
||||
if any(not destination.get(field) for field in required):
|
||||
return "destination_unresolved"
|
||||
if target == "briefed":
|
||||
return "briefed"
|
||||
|
||||
root = Path(destination["frontend"]).resolve()
|
||||
locations = [Path(p).resolve() for p in facts["implementation_files"]]
|
||||
if not locations or any(not p.is_relative_to(root) or not p.is_file() for p in locations):
|
||||
return "outside_authoritative_app"
|
||||
if not facts["route_connected"]:
|
||||
return "route_missing"
|
||||
if not facts["navigation_connected"]:
|
||||
return "navigation_missing"
|
||||
if facts["backend_required"] and not facts["backend_connected"]:
|
||||
return "backend_missing"
|
||||
if target == "implementation_complete":
|
||||
return "implementation_complete"
|
||||
|
||||
if not facts["automated_checks"]:
|
||||
return "automated_unverified"
|
||||
if not facts["real_environment"]:
|
||||
return "real_environment_unavailable"
|
||||
if not facts["real_route_tested"]:
|
||||
return "real_route_unverified"
|
||||
if facts["auth_required"] and not facts["auth_tested"]:
|
||||
return "auth_unverified"
|
||||
if facts["backend_required"] and not facts["real_data_tested"]:
|
||||
return "real_data_unverified"
|
||||
if not facts["contributor_accepted"] or not facts["review_submitted"]:
|
||||
return "review_pending"
|
||||
if target == "ready_for_review":
|
||||
return "ready_for_review"
|
||||
|
||||
if not facts["captain_approved"] or not facts["merged"]:
|
||||
return "integration_pending"
|
||||
if not facts["combined_validated"]:
|
||||
return "combined_unverified"
|
||||
if target == "integrated":
|
||||
return "integrated"
|
||||
return "verified_closed" if facts["human_accepted"] else "acceptance_pending"
|
||||
|
||||
|
||||
class ApplicationDeliveryDecisionFixtures(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
root = Path(self.temp.name)
|
||||
app = root / "existing application" / "client"
|
||||
app.mkdir(parents=True)
|
||||
page = app / "new-screen.txt"
|
||||
page.write_text("feature in existing application\n")
|
||||
self.preview = root / "standalone preview" / "new-screen.txt"
|
||||
self.preview.parent.mkdir()
|
||||
self.preview.write_text("attractive preview\n")
|
||||
self.app_page = page
|
||||
self.facts = {
|
||||
"kind": "feature", "prototype_approved": False, "prototype_delivered": False,
|
||||
"destination": {
|
||||
"frontend": str(app), "routing": "existing route registry",
|
||||
"route": "/new-screen", "screen": "existing home screen",
|
||||
"navigation": "main menu", "auth": "signed-in team member",
|
||||
"backend": "configured service", "data": "persistent records",
|
||||
"environment": "project manual-test launcher", "conventions": "route tests",
|
||||
"design": "accepted version", "baseline": "integration commit",
|
||||
"acceptance": "screen works in main application",
|
||||
},
|
||||
"implementation_files": [str(page)], "route_connected": True,
|
||||
"navigation_connected": True, "backend_required": True,
|
||||
"backend_connected": True, "automated_checks": True,
|
||||
"real_environment": True, "real_route_tested": True,
|
||||
"auth_required": True, "auth_tested": True, "real_data_tested": True,
|
||||
"contributor_accepted": True, "review_submitted": True,
|
||||
"captain_approved": True, "merged": True,
|
||||
"combined_validated": True, "human_accepted": True,
|
||||
}
|
||||
|
||||
def test_destination_and_prototype_decisions(self):
|
||||
self.assertEqual(decision(self.facts, "briefed"), "briefed") # 1
|
||||
prototype = copy.deepcopy(self.facts)
|
||||
prototype.update(kind="prototype", prototype_approved=True, prototype_delivered=True,
|
||||
implementation_files=[str(self.preview)])
|
||||
self.assertEqual(decision(prototype, "prototype_complete"), "prototype_complete") # 2
|
||||
self.assertEqual(decision(prototype, "verified_closed"), "prototype_only")
|
||||
for change, target, expected in (
|
||||
({"implementation_files": [str(self.preview)]}, "implementation_complete", "outside_authoritative_app"), # 3, 4
|
||||
({}, "implementation_complete", "implementation_complete"), # 5
|
||||
({"navigation_connected": False}, "ready_for_review", "navigation_missing"), # 6
|
||||
({"backend_connected": False}, "ready_for_review", "backend_missing"), # 7
|
||||
({"auth_tested": False}, "ready_for_review", "auth_unverified"), # 8
|
||||
({"real_environment": False}, "ready_for_review", "real_environment_unavailable"), # 9
|
||||
({"real_route_tested": False}, "ready_for_review", "real_route_unverified"), # 10
|
||||
({"merged": True, "combined_validated": False}, "integrated", "combined_unverified"), # 11, 12
|
||||
({"combined_validated": False}, "verified_closed", "combined_unverified"), # 13
|
||||
({"captain_approved": False, "merged": False}, "integrated", "integration_pending"), # 14
|
||||
({"human_accepted": False}, "verified_closed", "acceptance_pending"), # 15
|
||||
):
|
||||
with self.subTest(change=change, target=target):
|
||||
facts = copy.deepcopy(self.facts)
|
||||
facts.update(change)
|
||||
self.assertEqual(decision(facts, target), expected)
|
||||
|
||||
def test_two_previews_do_not_become_two_integrated_features(self):
|
||||
for task_id in ("TASK-114", "PI-123"):
|
||||
with self.subTest(task_id=task_id):
|
||||
facts = copy.deepcopy(self.facts)
|
||||
facts["implementation_files"] = [str(self.preview)]
|
||||
self.assertEqual(decision(facts, "verified_closed"), "outside_authoritative_app") # 16, 17
|
||||
|
||||
def test_missing_destination_and_review_submission(self):
|
||||
facts = copy.deepcopy(self.facts)
|
||||
facts["destination"]["route"] = ""
|
||||
self.assertEqual(decision(facts, "briefed"), "destination_unresolved")
|
||||
facts = copy.deepcopy(self.facts)
|
||||
facts["review_submitted"] = False
|
||||
self.assertEqual(decision(facts, "ready_for_review"), "review_pending")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user