test(clients/python): commit before force_tick in 2 tests#139
Conversation
The two affected tests insert a message via client.send / client.send_batch and immediately call pgque.force_tick + pgque.ticker without committing in between. Because the tick captures a snapshot of currently-committed xacts, the just-inserted event is not visible to the tick, so pgque.receive returns an empty batch and the assertions fail. The other tests in the same file already commit between send and tick; this brings the two regressed tests in line with that pattern.
REV review — PR #139Verdict: PASS (non-blocking nit) 1. SecurityN/A — test-only. 2. Bugs / root causeFix is correct and addresses root cause. 3. Test analysisBoth test bodies still assert what their names claim:
4. Guidelines
5. DocsN/A. 6. ArchitectureCLAUDE.md rule (drivers mirror SQL API 1:1): unchanged — no public client API touched, no composite "send-then-tick" client method invented. Consistent with #129. Non-blocking observation: this is the third Python PR in the sprint to land on the same "commit between send and force_tick" footgun (#129 established the pattern; this PR fixes two stragglers that were merged before that pattern was widespread). Recommend a small private test helper, e.g. # clients/python/tests/_helpers.py
def commit_then_advance(conn, queue: str) -> None:
"""Commit producer xact, then force a tick so ticker() sees the events."""
conn.commit()
conn.execute("select pgque.force_tick(%s)", (queue,))
conn.execute("select pgque.ticker()")
conn.commit()Then call LGTM to merge once Generated by Claude Code |
Summary
Two Python tests regressed on the live-pg test job because they call
pgque.force_tick+pgque.tickerin the same transaction as the precedingclient.send/client.send_batch, without committing in between.pgque.ticker()captures a snapshot of currently-committed xacts, so an event inserted in the same still-open xact is not visible to the tick. The subsequentpgque.receivetherefore returns an empty batch, and the dependent assertions fail.The other tests in the same files already commit between send and tick; this brings the two regressed tests in line with that pattern.
Failing tests fixed:
tests/test_consumer.py::test_consumer_warns_and_acks_unhandled_event_typetests/test_send.py::test_send_batch_none_payload_produces_json_nullNo driver code is changed; both failures were test-only bugs about pgque snapshot semantics.
Test plan
pytest -v clients/python/tests/against a live PG withpgque.sqlfrommain-> 41/41 passPython client testsjob goes greenGenerated by Claude Code