Repository navigation
test(cover,door-entry): restore 100% coverage on cover.py and fix doorbell dispatcher race - #876
Merged
GreenGrassBlueOcean merged 1 commit intoNov 8, 2026
Conversation
…ispatcher callbacks
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 is the problem
CI on
v2-phase1-architecture(#232) is failing intest-coverageandPyPI Standards & Packaging(Run Pytest Suite & Coverage (Python 3.14)) for two distinct reasons:custom_components/myhome/cover.py(line 2675):MyHOMECover.handle_event()(lines 2666–2677) withif (is_closed := getattr(message, "is_closed", None)) is not None: ... else: self._attr_is_closed = (self._attr_current_cover_position == 0).test_poll_during_active_tilt_preserves_tilt_stateonly fed a parsedOWNAutomationEvent(*#2*0115*10*10*75*001*0##), wheremessage.is_closedisFalse(non-None), leaving line 2675 at0hits (18,735 / 18,736statements =99.9%) and causingscripts/update_readme_coverage.py/scripts/verify_ownd_coverage.pyto fail with exit code1.tests/test_door_entry_events.py::test_doorbell_fires_once_on_a_shared_bus:pri_dispatched.append(a C builtin method without@callback) directly toasync_dispatcher_connect.pri_dispatched.appendlacks_hass_callback = Trueand is not a coroutine function, Home Assistant classifies it asHassJobType.Executorand schedules it on a background thread-pool worker instead of running it inline on the event loop. Under CI load,assert len(pri_dispatched) == 1on line 246 evaluated0on the event loop thread microseconds before the worker thread appended the payload (the exact race class fixed intests/test_multi_gateway.pyby fix(test): wrap test dispatcher callbacks with callback() to eliminate executor thread race #850).async_dispatcher_connectandhass.bus.async_listenlisteners acrosstests/andcustom_components/myhome/also found un-decorated listeners intests/test_issue_667_intercom_trace.py.Addresses #232
Related to #850, #868, #870
What is the solution
is_closed is Nonefallback during active Venetian slat tilt (tests/test_issue_868_venetian_tilt_mhs1_trace.py):test_poll_during_active_tilt_preserves_tilt_statewith aMagicMock(spec=OWNAutomationEvent)status poll message carryingis_closed = Nonewhile_is_tiltingisTrue, restoring strict100.0%statement coverage (18,736 / 18,736statements across all 76 integration modules).@callback/callback(...)(tests/test_door_entry_events.py,tests/test_issue_667_intercom_trace.py):pri_dispatched.appendincallback(lambda payload: pri_dispatched.append(payload))intest_doorbell_fires_once_on_a_shared_bussoasync_dispatcher_sendinvokes it synchronously on the event loop._capture_dispatcherwith@callbackand wrap thehass.bus.async_listenlambdas withcallback(...)intests/test_issue_667_intercom_trace.py.State Diagram
N/A — test-only CI and coverage fix (no runtime state machine changes).
Hardware Verification
How is it tested
tests/test_issue_868_venetian_tilt_mhs1_trace.py::test_poll_during_active_tilt_preserves_tilt_state:cover.pyline 2675 (is_closed is Nonefallback during active tilt pulse) and verifies1,874 / 1,874(100.0%) statements incustom_components/myhome/cover.py.tests/test_door_entry_events.py::test_doorbell_fires_once_on_a_shared_bus:@callbackdelivery of failovermyhome_doorbell_event_{mac}dispatcher signals without executor thread races.tests/test_issue_667_intercom_trace.py:@callbackbus and dispatcher capture across all 3 trace replay tests.OWNd==2.0.0b13:scripts/verify_ownd_coverage.py: 76/76 modules at 100.0% (18,736 / 18,736statements, 0 missing).ruff check custom_components tests scripts: 0 violations.scripts/verify_ha_standards.py: PASS (54/54 Platinum rules).scripts/sync_documentation.py --check: PASS.Where are the traces
tests/fixtures/traces/issue_868/myhome_trace_MyHomeServer1_venetian_blind_75_2026-11-05.jsonandtests/fixtures/traces/mh200_intercom_gate_trace.json) unchanged.What does the Firmware Oracle / Encyclopedia say
WHO/WHAT/Dimensionprotocol changes.Checklist
What is the problem,What is the solution,State Diagram,How is it tested,Where are the traces,What does the Firmware Oracle / Encyclopedia say).handle_event()and do not manually subscribe viaasync_dispatcher_connect.pytest,ruff, andscripts/verify_ha_standards.pypass.