Skip to content

fix: type-check session in fake cancel_timer and fetch_unprocessed - #246

Merged
lesnik512 merged 1 commit into
mainfrom
fix/fake-session-guard
Oct 17, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
fix/fake-session-guard

Conversation

@lesnik512

Copy link
Copy Markdown
Member

FakeOutboxClient.cancel_timer and fetch_unprocessed dropped the session argument without looking at it. OutboxClient calls require_session_or_connection first, so under TestOutboxBroker a call with session=None or session=object() passed, while the same call raises TypeError in production.

The fake now calls the same guard with FakeOutboxClient.<method> as the context, so its message has the same shape as the real client's.

  • A new case in tests/test_client_contract.py calls both methods with None and object() on the fake and real clients. It failed on the fake before the fix. The suite's docstring scope line now mentions it.
  • Several tests/test_fake.py tests passed session=object() behind a ty: ignore. They now pass fake_session().
  • docs/usage/testing.md said the session is ignored in tests. It now says it must still be an AsyncSession or AsyncConnection.

Follow-up to #244, whose review found the gap.

just lint is clean; just test: 762 passed.

FakeOutboxClient ignored the session argument, so TestOutboxBroker accepted
session=None or a random object where OutboxClient raises TypeError. The fake
now calls the same require_session_or_connection guard. A contract test runs
the check against both clients.
@github-actions

Copy link
Copy Markdown

Benchmark gate

✅ gate passed

scenario msg/s delete/msg WALrec/msg WALB/msg fpi upd del dead_tup
consumer/w1/b10 1328 1.000 6.73 923 242 5000 5000 10000
consumer/w1/b100 1431 1.000 7.11 1154 243 5000 5000 10000
consumer/w2/b10 1603 1.000 6.72 923 242 5000 5000 10000
consumer/w2/b100 1853 1.000 7.11 1154 243 5000 5000 10000
consumer/w4/b10 1656 1.000 6.77 951 242 5000 5000 10000
consumer/w4/b100 1970 1.000 7.11 1152 243 5000 5000 10000
consumer/w1/b100/tfbs100 5577 0.010 6.11 1130 243 5000 5000 10000
consumer/w1/b100/interval1-10 1462 1.000 7.17 1196 265 5000 5000 10000
producer/w1/b100 3005 0.000 3.04 597 1 0 0 0
producer/w1/b100/ppt1 1007 0.000 4.04 635 0 0 0 0

Gated (fails the build): delete_calls + tuple counters (upd/del/ins) + the producer's insert_calls, exact; select_calls and other_calls within +2; wal_records within a 10% band; fetch_calls within 2x. msg/s, WAL bytes and total calls are informational (timing/FPI noise).

@lesnik512
lesnik512 merged commit 62cdd90 into main Oct 17, 2026
13 checks passed
@lesnik512
lesnik512 deleted the fix/fake-session-guard branch October 17, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant