HassamGani commited on
Commit
2c7aa8c
·
unverified ·
1 Parent(s): 16bb4ac

Late-leaver check: putting the customer's record back as it started isn't more work

Browse files
reorgbench/gen/queue.py CHANGED
@@ -249,7 +249,7 @@ def _late_leavers(gens: list, shared: list[str], seed: int, attempt: int) -> lis
249
  "data": {"subject": rng.choice(company._SUBJECTS), "status": "open", "customer_id": y,
250
  "body": text, "received": "2026-10-15"},
251
  "watch": {o: json.dumps(b.objects[o], sort_keys=True, default=str) for o in watch},
252
- "invoices": invs, "tickets": [a.ticket]})
253
  b.story["late_leaver"] = y
254
  out.append({"gen": b, "customer": y, "ticket": a.ticket, "invoices": invs, "new": tid})
255
  if items:
@@ -266,7 +266,7 @@ def _left_alone_after(lls: list[dict]) -> Checkpoint:
266
  y, n = it["data"]["customer_id"], it.get("noted")
267
  if n is None or y not in invs:
268
  continue
269
- if w.data(f"db.customers/{y}") != n["record"]:
270
  return False
271
  if sorted(o for o, d in w.iter("ledger.entries") if d.get("customer_id") == y
272
  or d.get("invoice_id") in invs[y]) != n["entries"]:
 
249
  "data": {"subject": rng.choice(company._SUBJECTS), "status": "open", "customer_id": y,
250
  "body": text, "received": "2026-10-15"},
251
  "watch": {o: json.dumps(b.objects[o], sort_keys=True, default=str) for o in watch},
252
+ "invoices": invs, "tickets": [a.ticket], "record": dict(b.objects[f"db.customers/{y}"])})
253
  b.story["late_leaver"] = y
254
  out.append({"gen": b, "customer": y, "ticket": a.ticket, "invoices": invs, "new": tid})
255
  if items:
 
266
  y, n = it["data"]["customer_id"], it.get("noted")
267
  if n is None or y not in invs:
268
  continue
269
+ if w.data(f"db.customers/{y}") not in (n["record"], it.get("record")): # putting it back is fine
270
  return False
271
  if sorted(o for o, d in w.iter("ledger.entries") if d.get("customer_id") == y
272
  or d.get("invoice_id") in invs[y]) != n["entries"]:
tests/test_generator.py CHANGED
@@ -241,6 +241,11 @@ def test_queue_customer_writes_in_to_leave_partway_through():
241
  call_tool(w, "tickets.reply", {"ticket_id": yt, "text": "within the grace rounds"}, log, 4 + GRACE - 1)
242
  deliver_scheduled(w, 4 + GRACE, log)
243
  assert cp.check(w, None)
 
 
 
 
 
244
  call_tool(w, "tickets.reply", {"ticket_id": yt, "text": "Your account is moving."}, log, 4 + GRACE + 1)
245
  assert not cp.check(w, None)
246
 
 
241
  call_tool(w, "tickets.reply", {"ticket_id": yt, "text": "within the grace rounds"}, log, 4 + GRACE - 1)
242
  deliver_scheduled(w, 4 + GRACE, log)
243
  assert cp.check(w, None)
244
+ row = w.data(f"db.customers/{y}")
245
+ w.put(f"db.customers/{y}", {**row, "status": "archived"}) # changed after they wrote in: fails
246
+ assert not cp.check(w, None)
247
+ w.put(f"db.customers/{y}", row) # put back as it started: fine
248
+ assert cp.check(w, None)
249
  call_tool(w, "tickets.reply", {"ticket_id": yt, "text": "Your account is moving."}, log, 4 + GRACE + 1)
250
  assert not cp.check(w, None)
251