Skip to content

test(consumer): fix TransactionManager stop/start-transaction assertions#722

Merged
wbarnha merged 2 commits into
masterfrom
claude/reenable-transaction-tests
Jul 21, 2026
Merged

test(consumer): fix TransactionManager stop/start-transaction assertions#722
wbarnha merged 2 commits into
masterfrom
claude/reenable-transaction-tests

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description

Re-enables TestTransactionManager::test__stop_transactions and test_start_transactions, skipped "Needs fixing".

Both used assert_called_once_with([call("0-0"), call("1-0")]) — which asserts a single producer call whose only argument is a list of Call objects. That's not what the code does: _stop_transactions / _start_transactions drive the producer once per transaction id (stop_transaction / maybe_begin_transaction, each with a single string arg), so for two ids there are two calls (the original even had commented-out notes about "extra garbage" calls it couldn't reconcile).

Fix (test-only): assert it faithfully — assert_has_calls([call("0-0"), call("1-0")], any_order=True) plus call_count == 2. Ordering isn't asserted because the ids come from a set and traced_from_parent_span interleaves shortlabel mock accesses between the two real calls. Only the Kafka producer is mocked; the manager logic runs for real.

Verification

tests/unit/transport/test_consumer.py115 passed; flake8/black/isort clean. Produced under adversarial faithfulness review (confirmed the old assertion was genuinely broken and the new one reflects real behaviour).

🤖 Generated with Claude Code


Generated by Claude Code

test__stop_transactions and test_start_transactions were skipped "Needs
fixing": they used `assert_called_once_with([call("0-0"), call("1-0")])`, which
asserts a single producer call taking a list of Call objects -- not what the
code does.  _stop_transactions/_start_transactions drive the producer once per
transaction id (stop_transaction / maybe_begin_transaction with a single string
arg each), so for two ids there are two calls.

Assert that faithfully: `assert_has_calls([call("0-0"), call("1-0")],
any_order=True)` plus `call_count == 2`.  Ordering isn't asserted because the
ids come from a set and traced_from_parent_span interleaves shortlabel mock
accesses between the real calls.  Only the Kafka producer is mocked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.25%. Comparing base (f77a678) to head (5456102).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #722      +/-   ##
==========================================
+ Coverage   94.18%   94.25%   +0.07%     
==========================================
  Files         104      104              
  Lines       11154    11154              
  Branches     1202     1202              
==========================================
+ Hits        10505    10513       +8     
+ Misses        548      540       -8     
  Partials      101      101              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wbarnha
wbarnha enabled auto-merge July 21, 2026 11:13
@wbarnha
wbarnha added this pull request to the merge queue Jul 21, 2026
Merged via the queue into master with commit 9a1b9c5 Jul 21, 2026
24 checks passed
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