92 lines
5.2 KiB
Python
92 lines
5.2 KiB
Python
import unittest
|
|
|
|
from prepare_business_acceptance_batch import candidates
|
|
|
|
|
|
class WorkflowDeliveryPriorityTests(unittest.TestCase):
|
|
def state(self):
|
|
rows = [
|
|
{"id": "product:desktop-workspace-parity", "module": "Web", "command": "workspace", "acceptanceRequired": True},
|
|
{"id": "Part:desktop:Part_Primitives", "module": "Part", "command": "Part_Primitives"},
|
|
{"id": "Sketcher:desktop:Constraint", "module": "Sketcher", "command": "Constraint"},
|
|
{"id": "TechDraw:desktop:Drawing", "module": "TechDraw", "command": "Drawing"},
|
|
]
|
|
return {"pending": rows, "covered": {name: set() for name in ["Web", "Part", "Sketcher", "TechDraw"]},
|
|
"cooling": set(), "receipts": {}, "deferredValidation": set(), "history": [],
|
|
"deliveryPolicy": {"enabled": True, "priorityIds": ["product:desktop-workspace-parity"],
|
|
"moduleOrder": ["Web", "Sketcher", "Part", "TechDraw"], "historyWindow": 8,
|
|
"maxModuleTurns": 3, "maxUnfinishedAttempts": 2, "breadthEvery": 4}}
|
|
|
|
def first(self, state):
|
|
return candidates(state, uncovered_only=True)[0]["module"]
|
|
|
|
def test_primary_integration_gap_precedes_generic_command_backlog(self):
|
|
self.assertEqual(self.first(self.state()), "Web")
|
|
|
|
def test_repeated_unfinished_package_rotates_without_removing_requirements(self):
|
|
state = self.state()
|
|
state["history"] = [{"cycle": n, "module": "Web", "outcome": "source_edits_pending_outcome",
|
|
"deferredIds": ["product:desktop-workspace-parity"], "firstBusinessPassIds": []} for n in [100, 101]]
|
|
self.assertEqual(self.first(state), "Sketcher")
|
|
selected = {row["id"] for group in candidates(state) for row in group["rows"]}
|
|
self.assertEqual(selected, {row["id"] for row in state["pending"]})
|
|
|
|
def test_successful_module_also_leaves_room_for_other_workbenches(self):
|
|
state = self.state()
|
|
state["history"] = [{"cycle": n, "module": "Web", "outcome": "progress", "firstBusinessPassIds": [f"done{n}"]}
|
|
for n in [101, 102, 104]]
|
|
self.assertEqual(self.first(state), "Sketcher")
|
|
|
|
def test_unfinished_attempts_rotate_before_a_cooldown_record_exists(self):
|
|
state = self.state()
|
|
state["history"] = [{"cycle": n, "module": "Web", "outcome": "source_edits_pending_outcome",
|
|
"selectedIds": ["product:desktop-workspace-parity"], "deferredIds": [],
|
|
"firstBusinessPassIds": []} for n in [100, 101]]
|
|
self.assertEqual(self.first(state), "Sketcher")
|
|
|
|
def test_breadth_reservation_uses_cycle_not_saturated_history_length(self):
|
|
state = self.state()
|
|
state["deliveryPolicy"].update(maxModuleTurns=1000, maxUnfinishedAttempts=1000)
|
|
state["history"] = [{"cycle": n, "module": "Web", "outcome": "progress"} for n in range(104, 204)]
|
|
self.assertEqual(len(state["history"]), 100)
|
|
self.assertEqual(self.first(state), "Sketcher")
|
|
state["history"].append({"cycle": 204, "module": "Sketcher", "outcome": "progress"})
|
|
self.assertEqual(self.first(state), "Web")
|
|
|
|
def test_provider_wait_is_not_a_module_or_unfinished_attempt(self):
|
|
state = self.state()
|
|
state["history"] = [{"cycle": n, "module": "Web", "outcome": "provider_wait",
|
|
"deferredIds": ["product:desktop-workspace-parity"]} for n in range(20)]
|
|
self.assertEqual(self.first(state), "Web")
|
|
|
|
def test_rotation_never_causes_idle_when_only_one_group_remains(self):
|
|
state = self.state()
|
|
state["pending"] = state["pending"][:1]
|
|
state["history"] = [{"cycle": n, "module": "Web", "outcome": "source_edits_pending_outcome",
|
|
"deferredIds": ["product:desktop-workspace-parity"]} for n in range(1, 9)]
|
|
self.assertEqual(self.first(state), "Web")
|
|
|
|
def test_history_passes_and_cooling_remain_excluded(self):
|
|
state = self.state()
|
|
state["deferredValidation"] = {"product:desktop-workspace-parity"}
|
|
state["cooling"] = {"Sketcher:desktop:Constraint"}
|
|
self.assertEqual(self.first(state), "Part")
|
|
|
|
def test_inventory_and_api_routes_do_not_preempt_user_workflows(self):
|
|
state = self.state()
|
|
state["pending"] = [{"id": "Web:web.pythonApi", "module": "Web", "command": "web.pythonApi"},
|
|
{"id": "TechDraw:desktop:Drawing", "module": "TechDraw", "command": "Drawing"}]
|
|
self.assertEqual(self.first(state), "TechDraw")
|
|
|
|
def test_known_missing_implementation_precedes_case_only_backlog(self):
|
|
state = self.state()
|
|
state["pending"] = [{"id": "Web:desktop:Ready", "module": "Web", "command": "Ready", "implementationStatus": "routed"},
|
|
{"id": "TechDraw:desktop:Missing", "module": "TechDraw", "command": "Missing", "implementationStatus": "implementation_required"}]
|
|
self.assertEqual(self.first(state), "TechDraw")
|
|
state["covered"]["TechDraw"].add("TechDraw:desktop:Missing")
|
|
self.assertEqual(self.first(state), "TechDraw", "Existing tests must not hide a known implementation gap")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|