test: cover manager.py uncovered branches - #425
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
bdraco
marked this pull request as ready for review
May 17, 2026 23:02
bdraco
approved these changes
May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Six targeted unit tests for previously-uncovered branches in
BluetoothManager.No production code touched.
Why
manager.pysat at 91% line coverage with a long tail of trivially-reachablebranches that nothing in the suite exercised: the
connectable=Falsearms ofthe count / address-present / track-unavailable helpers, the unknown-source
short-circuit in
async_current_allocations, the early-return when_async_recover_failed_adaptersre-enters with the lock held, and thecached=Falserefresh path onasync_get_bluetooth_adapters. They're cheapto cover and they regress silently if anyone reshapes the helpers.
Complements #424 (which targets
scanner.pyerror paths).How
test_async_scanner_count_includes_non_connectable— registers one of each,asserts
connectable=TruevsFalsetotals diverge.test_async_address_present_non_connectable_history— injects anon-connectable advertisement and asserts the all-history branch.
test_async_track_unavailable_connectable_branch— the only existingcallers used
connectable=False; this hits theTruearm and verifiesthe callback lands in
_connectable_unavailable_callbacks.test_async_current_allocations_unknown_source_returns_empty—[]vsNonefor a missing source.test_async_recover_failed_adapters_skips_when_lock_held— pre-acquiresthe recovery lock, asserts
async_get_bluetooth_adaptersis not called.test_async_get_bluetooth_adapters_cached_false_triggers_refresh— patches_bluetooth_adapters.refreshand assertscached=Falseawaits it.Testing
SKIP_CYTHON=1 poetry run pytest tests/ -W "error::DeprecationWarning" -W "ignore::DeprecationWarning:asyncio"→ 249 passed, 1 skipped.manager.pycoverage 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