HEL-282: 写库路径事务提交与审计留痕自查修复
同类未提交即 close 回滚、业务与审计拆成两笔事务的路径一并收进可嵌套事务边界。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
9e0e4a103a
commit
9193a3fce0
@@ -943,6 +943,38 @@ class ProjectionRebuildTests(MatchingBase):
|
||||
self.assertEqual(sorted(before), sorted(after))
|
||||
self.assertEqual(sorted(claims_before), sorted(claims_after))
|
||||
|
||||
def test_rebuild_clears_stale_projection_and_survives_close(self) -> None:
|
||||
"""HEL-282: DELETEs used to stay uncommitted when nothing was restored."""
|
||||
from bank_importer.db import connect as db_connect
|
||||
|
||||
row_a = self.add_row(
|
||||
self.company_a, own_account="6222000000000001",
|
||||
cp_account="6222000000000002", expense="100.00",
|
||||
)
|
||||
row_b = self.add_row(
|
||||
self.company_b, own_account="6222000000000002",
|
||||
cp_account="6222000000000001", income="100.00",
|
||||
)
|
||||
matching.reconcile_rows(self.connection, [row_a, row_b])
|
||||
with self.connection:
|
||||
self.connection.execute(
|
||||
"UPDATE canonical_transfer_events SET lifecycle = 'superseded'"
|
||||
)
|
||||
matching.rebuild_current_projection(self.connection)
|
||||
self.connection.close()
|
||||
fresh = db_connect(self.db_path)
|
||||
try:
|
||||
remaining = fresh.execute(
|
||||
"SELECT COUNT(*) AS n FROM current_transfer_decisions"
|
||||
).fetchone()["n"]
|
||||
claims = fresh.execute(
|
||||
"SELECT COUNT(*) AS n FROM transfer_observation_claims"
|
||||
).fetchone()["n"]
|
||||
finally:
|
||||
fresh.close()
|
||||
self.assertEqual(0, remaining)
|
||||
self.assertEqual(0, claims)
|
||||
|
||||
|
||||
class ConcurrentReconcileTests(MatchingBase):
|
||||
def test_concurrent_reconcile_creates_one_event(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user