fix(test): test_849 expects 3 begin_nested/lot after #1921 upsert-reconcile SAVEPOINT — unblock red main gate (#1925)
All checks were successful
Deploy Trade-In / changes (push) Successful in 10s
Deploy Trade-In / build-browser (push) Has been skipped
Deploy Trade-In / build-frontend (push) Successful in 28s
Deploy Trade-In / test (push) Successful in 1m24s
Deploy Trade-In / build-backend (push) Successful in 53s
Deploy Trade-In / deploy (push) Successful in 51s

This commit is contained in:
bot-backend 2026-06-26 17:23:24 +00:00
parent d89210200b
commit 87364eebca

View file

@ -309,13 +309,16 @@ class TestSingleSavepointBatchIsolation:
save_listings(db, lots)
# save_listings calls begin_nested once per lot for the snapshot
# and once per lot for the hook — so 2 * len(lots) total.
# If _link_listing_to_house opens an INNER begin_nested too,
# the count would be > 2 * len(lots).
# (snapshot SAVEPOINT + hook SAVEPOINT = 2 per lot, no extra inner)
assert db.begin_nested.call_count == 2 * len(lots), (
f"Expected exactly 2 begin_nested per lot (snapshot + hook outer), "
# save_listings calls begin_nested THREE times per lot:
# 1) upsert SAVEPOINT — ловит IntegrityError на UNIQUE(source,source_id)
# (migration 133) при dedup_hash-дрейфе → rollback + прямой UPDATE (#1921);
# 2) snapshot SAVEPOINT;
# 3) hook SAVEPOINT (_link_listing_to_house).
# If _link_listing_to_house opened an INNER begin_nested too,
# the count would be > 3 * len(lots). The intent of this test (no double-nesting
# INSIDE the hook) holds — base.py keeps exactly one SAVEPOINT level in the hook.
assert db.begin_nested.call_count == 3 * len(lots), (
f"Expected exactly 3 begin_nested per lot (upsert + snapshot + hook outer), "
f"got {db.begin_nested.call_count} — inner SAVEPOINT may still be present"
)