From 87364eebcadac361974992ff3c0a4328fa7752c8 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Fri, 26 Jun 2026 17:23:24 +0000 Subject: [PATCH] =?UTF-8?q?fix(test):=20test=5F849=20expects=203=20begin?= =?UTF-8?q?=5Fnested/lot=20after=20#1921=20upsert-reconcile=20SAVEPOINT=20?= =?UTF-8?q?=E2=80=94=20unblock=20red=20main=20gate=20(#1925)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/test_849_matching_savepoint.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tradein-mvp/backend/tests/test_849_matching_savepoint.py b/tradein-mvp/backend/tests/test_849_matching_savepoint.py index 297ae453..b67ae4f4 100644 --- a/tradein-mvp/backend/tests/test_849_matching_savepoint.py +++ b/tradein-mvp/backend/tests/test_849_matching_savepoint.py @@ -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" )