Recover inventory items from severely malformed VLM JSON
This commit is contained in:
@@ -41,6 +41,17 @@ class ClothingLayoutPlannerTests(unittest.TestCase):
|
||||
raw = inventory({"id": "hat", "name": "hat"}) + "\nHere is the inventory."
|
||||
self.assertEqual(PLANNER.normalize_inventory(raw)[0]["id"], "hat")
|
||||
|
||||
def test_salvages_schema_items_when_json_repair_cannot_parse(self):
|
||||
raw = '{"items":[{"id":"shirt","name":"shirt","quantity":1,"description":"blue shirt'
|
||||
original_repair = PLANNER._repair_vlm_json
|
||||
PLANNER._repair_vlm_json = lambda _text: '{broken'
|
||||
try:
|
||||
items = PLANNER.normalize_inventory(raw)
|
||||
finally:
|
||||
PLANNER._repair_vlm_json = original_repair
|
||||
self.assertEqual(items[0]["id"], "shirt")
|
||||
self.assertEqual(items[0]["description"], "blue shirt")
|
||||
|
||||
def test_quantities_and_pairs_create_deterministic_instances(self):
|
||||
plan = PLANNER.plan_layout(inventory(
|
||||
{"id": "sock", "name": "sock", "quantity": 3},
|
||||
|
||||
Reference in New Issue
Block a user