This commit is contained in:
@@ -104,6 +104,26 @@ def test_continual_plan_store_creates_buying_checklist(tmp_path):
|
||||
assert plan["items"][0]["desired_quantity"] == 2
|
||||
|
||||
|
||||
def test_continual_plan_store_deletes_plan_and_related_records(tmp_path):
|
||||
_, store, _, _, _ = plan_stack(tmp_path)
|
||||
|
||||
plan = store.create_plan(
|
||||
"Delete me",
|
||||
objective="Remove everything",
|
||||
items=[{"item_name": "Wikelo Idris panel", "desired_quantity": 1}],
|
||||
)
|
||||
item_id = int(plan["items"][0]["id"])
|
||||
candidate = store.upsert_candidate(plan["id"], item_id, {"id": "listing-1", "title": "Panel", "price": 10}, 0.9)
|
||||
store.add_negotiation(plan["id"], item_id, int(candidate["id"]), {"listing_id": "listing-1", "listing_slug": "panel", "id_negotiation": "neg-1", "hash": "hash-1"})
|
||||
|
||||
assert store.delete_plan(plan["id"]) is True
|
||||
assert store.get_plan(plan["id"]) is None
|
||||
assert store.list_items(plan["id"]) == []
|
||||
assert store.list_candidates(plan["id"]) == []
|
||||
assert store.list_negotiations(plan["id"]) == []
|
||||
assert store.list_events(plan["id"]) == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_buying_runner_tracks_candidates_and_drafts_only(tmp_path):
|
||||
memory, store, tools, runner, _ = plan_stack(tmp_path)
|
||||
@@ -215,3 +235,19 @@ async def test_scheduler_schedules_overdue_plan_catchup_on_start(tmp_path):
|
||||
|
||||
assert catchup is not None
|
||||
assert any(event["kind"] == "catchup_scheduled" for event in snapshot["events"])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tools_delete_continual_plan_removes_it(tmp_path):
|
||||
_, store, tools, _, _ = plan_stack(tmp_path)
|
||||
plan = store.create_plan(
|
||||
"Delete through tools",
|
||||
objective="Remove via registry",
|
||||
items=[{"item_name": "Wikelo Idris panel"}],
|
||||
)
|
||||
|
||||
result = await tools.delete_continual_plan(plan["id"])
|
||||
|
||||
assert result["deleted"] is True
|
||||
assert result["plan_id"] == plan["id"]
|
||||
assert store.get_plan(plan["id"]) is None
|
||||
|
||||
Reference in New Issue
Block a user