Answer stability round 1: 0 🔴, 3 🟡 (0 misread); catch only Unreadable around the decode, test each required field and the id list's type, reword the decoders' docstrings as the prose round asked
This commit is contained in:
@@ -1778,7 +1778,7 @@ class LoopRuns(unittest.TestCase):
|
||||
self.assertEqual(set(reload.LOOP_RUN_FIELDS), {field.name for field in dataclasses.fields(main.LoopRun)})
|
||||
self.assertEqual(set(reload.ROUTE_FIELDS), {field.name for field in dataclasses.fields(Route)})
|
||||
|
||||
def test_rejects_a_field_of_the_state_or_its_route_of_another_type(self):
|
||||
def test_rejects_a_field_of_another_type_or_an_unknown_field(self):
|
||||
state = dataclasses.asdict(main.LoopRun(cycle_number=2, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("claude-opus-5-5", "high"), 3, 4, 5, 1, 7, 9), unfinished_run=2))
|
||||
for path, wrong in ((("unfinished_run",), "2"), (("unfinished_run",), True), (("route", "unfinished"), 1.0), (("route", "escalated_at"), "9"), (("route", "item"), True), (("route", "rung"), "claude-opus-5-5"), (("route", "rung", "model"), None), (("route",), "r"), (("route", "extra"), 1)):
|
||||
with self.subTest(path=path, wrong=wrong):
|
||||
@@ -1789,6 +1789,17 @@ class LoopRuns(unittest.TestCase):
|
||||
target[path[-1]] = wrong
|
||||
self.assertIsNone(reload.decode_handed(json.dumps(handed)))
|
||||
|
||||
def test_rejects_a_state_or_rung_missing_a_required_field(self):
|
||||
state = dataclasses.asdict(main.LoopRun(cycle_number=2, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("claude-opus-5-5", "high"))))
|
||||
for path in (("cycle_number",), ("root",), ("task",), ("unfinished_evidence",), ("route", "rung"), ("route", "rung", "model")):
|
||||
with self.subTest(path=path):
|
||||
handed = json.loads(json.dumps(state))
|
||||
target = handed
|
||||
for key in path[:-1]:
|
||||
target = target[key]
|
||||
del target[path[-1]]
|
||||
self.assertIsNone(reload.decode_handed(json.dumps(handed)))
|
||||
|
||||
def test_decodes_a_rung_without_an_effort(self):
|
||||
state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("some-model")))
|
||||
self.assertEqual(reload.decode_handed(json.dumps({**dataclasses.asdict(state), "route": {"rung": {"model": "some-model"}}})), state)
|
||||
@@ -1830,7 +1841,7 @@ class LoopRuns(unittest.TestCase):
|
||||
def test_decodes_the_items_taken_in_as_a_tuple_of_ids(self):
|
||||
state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", items_taken_in=(12, 14))
|
||||
self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state))), state)
|
||||
for taken_in in ([12, "14"], [True], "12", {"12": 1}):
|
||||
for taken_in in ([12, "14"], [True], "12", {"12": 1}, "", {}):
|
||||
with self.subTest(taken_in=taken_in):
|
||||
self.assertIsNone(reload.decode_handed(json.dumps(dataclasses.asdict(state) | {"items_taken_in": taken_in})))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user