Add subscription-recovery acceptance tests; bump pytest-asyncio#4
Merged
Conversation
Encode the six fault-injection scenarios from the ops-side recovery spec (2026-05-21 Tawaret incident) as behavioral tests against the library's connection-event surface, including the priority false-recovery case where Tier-1 reports SUBSCRIPTION_RECOVERED yet the next poll still escalates to a Tier-2 forced reconnect. Two spec/library mismatches are handled explicitly: the 60s reconnect cooldown (deleted with the 0.11.0 gap watchdog) is re-expressed as the structural two-poll escalation gate, and integration-side counters (forced_reconnect_counts, last_subscription_mismatch) are mapped to event-stream assertions since they live in the HA coordinator, not this library. Also fix a stale trigger value in the _execute_forced_reconnect docstring (notify_stall -> subscription_mismatch) and bump pytest-asyncio to >=1.0, which drops the deprecated asyncio.get_event_loop_policy / iscoroutinefunction calls that produced ~18k DeprecationWarnings under Python 3.14 (no effect on CI's 3.11-3.13 matrix). No release: tests, dev deps, and an internal docstring do not affect the published package.
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.
Summary
Encodes the six fault-injection scenarios from the ops-side recovery spec (2026-05-21 Tawaret incident) as behavioral tests against the library's connection-event surface. The priority case is the false recovery: Tier-1 re-subscribe fires
SUBSCRIPTION_RECOVERED(reports success) yet the next poll still diverges and escalates to a Tier-2 forced reconnect — locking in that escalation acts on the next poll's evidence, never Tier-1's self-report.No runtime/API change; no release (tests, dev deps, and an internal docstring don't ship in the published wheel).
Two spec/library mismatches, handled explicitly
forced_reconnect_counts/last_subscription_mismatchare integration-side (HA coordinator), not this library. Mapped to event-stream assertions (e.g.forced_reconnect_counts["subscription_mismatch"] == 1→ exactly oneFORCED_RECONNECTevent withdetail.trigger == "subscription_mismatch").Tests added (
tests/test_subscription_recovery_spec.py, 19 cases)MISMATCH→RECOVERED→MISMATCH→FORCED_RECONNECT→CONNECTED, clean poll afterFORCED_RECONNECTwithtrigger="poll_failure"Also
_execute_forced_reconnectdocstring (notify_stall→subscription_mismatch).pytest-asyncioto>=1.0(1.3.0), dropping the deprecatedasyncio.get_event_loop_policy/iscoroutinefunctioncalls that produced ~18kDeprecationWarnings under Python 3.14. No effect on the CI 3.11–3.13 matrix.Verification
pytest tests/ --cov=ooler_ble_client --cov-fail-under=100→ 399 passed, 100% coverage (0 warnings, was 18,249)mypy --strict ooler_ble_client/ tests/→ no issues in 13 files