Skip to content

test: cover manager.py uncovered branches - #425

Merged
bdraco merged 1 commit into
mainfrom
koan/cover-manager-uncovered-branches
May 17, 2026
Merged

test: cover manager.py uncovered branches#425
bdraco merged 1 commit into
mainfrom
koan/cover-manager-uncovered-branches

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented May 17, 2026

Copy link
Copy Markdown
Contributor

What

Six targeted unit tests for previously-uncovered branches in BluetoothManager.
No production code touched.

Why

manager.py sat at 91% line coverage with a long tail of trivially-reachable
branches that nothing in the suite exercised: the connectable=False arms of
the count / address-present / track-unavailable helpers, the unknown-source
short-circuit in async_current_allocations, the early-return when
_async_recover_failed_adapters re-enters with the lock held, and the
cached=False refresh path on async_get_bluetooth_adapters. They're cheap
to cover and they regress silently if anyone reshapes the helpers.

Complements #424 (which targets scanner.py error paths).

How

  • test_async_scanner_count_includes_non_connectable — registers one of each,
    asserts connectable=True vs False totals diverge.
  • test_async_address_present_non_connectable_history — injects a
    non-connectable advertisement and asserts the all-history branch.
  • test_async_track_unavailable_connectable_branch — the only existing
    callers used connectable=False; this hits the True arm and verifies
    the callback lands in _connectable_unavailable_callbacks.
  • test_async_current_allocations_unknown_source_returns_empty[] vs
    None for a missing source.
  • test_async_recover_failed_adapters_skips_when_lock_held — pre-acquires
    the recovery lock, asserts async_get_bluetooth_adapters is not called.
  • test_async_get_bluetooth_adapters_cached_false_triggers_refresh — patches
    _bluetooth_adapters.refresh and asserts cached=False awaits it.

Testing

  • SKIP_CYTHON=1 poetry run pytest tests/ -W "error::DeprecationWarning" -W "ignore::DeprecationWarning:asyncio" → 249 passed, 1 skipped.
  • manager.py coverage 91% → 94%; total 95% → 96%.

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 83 insertions(+)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Six targeted unit tests for previously-uncovered branches in
BluetoothManager:

- async_scanner_count(connectable=False) sums both pools.
- async_address_present(connectable=False) reads the all-history map.
- async_track_unavailable(connectable=True) stores in the connectable
  callback dict (the only call sites in the suite were connectable=False).
- async_current_allocations("<unknown source>") returns [] rather than None.
- _async_recover_failed_adapters is a no-op when the recovery lock is held.
- async_get_bluetooth_adapters(cached=False) forces refresh on the
  underlying adapters source.

No production code touched. manager.py coverage 91% → 94%; total 95% → 96%.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.92%. Comparing base (32db633) to head (b7225f0).
⚠️ Report is 195 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #425      +/-   ##
==========================================
+ Coverage   95.19%   95.92%   +0.73%     
==========================================
  Files          14       14              
  Lines        1913     1913              
  Branches      232      232              
==========================================
+ Hits         1821     1835      +14     
+ Misses         53       42      -11     
+ Partials       39       36       -3     

☔ 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.

@codspeed-hq

codspeed-hq Bot commented May 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing koan/cover-manager-uncovered-branches (b7225f0) with main (32db633)

Open in CodSpeed

@bdraco
bdraco marked this pull request as ready for review May 17, 2026 23:02
@bdraco
bdraco merged commit 47d4b71 into main May 17, 2026
42 checks passed
@bdraco
bdraco deleted the koan/cover-manager-uncovered-branches branch May 17, 2026 23:02
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.

2 participants