11 — Setup — Subsystem Test Map¶
The setup subsystem owns the integration lifecycle around a config entry: the guided setup workflow + progress, start-protection state, map deletion, and the room-drift detector (new/removed segments since last check). Covered by 198 tests across 9 files.
Source: custom_components/eufy_vacuum/setup/ (+ __init__.py entry wiring)
Architecture reference: 31 — The Setup Layer
Coverage map¶
| Source module | Stmts | Cov | Test files | Layer | Mocking |
|---|---|---|---|---|---|
drift.py |
360 | 96% | test_setup_drift.py, test_setup_drift_deep.py |
integration | clean |
workflow.py |
81 | 98% | test_setup_workflow.py, test_setup_workflow_deep.py |
integration | bare x1 |
status.py |
82 | 96% | test_setup_status.py |
integration | clean |
delete.py |
59 | 96% | test_setup_delete.py |
integration | clean |
protection.py |
37 | 96% | test_setup_protection.py (unit) |
unit | clean |
__init__.py |
0 | 100% | test_init_setup.py, test_manager_setup.py |
integration | bare x4 |
What's tested¶
- Workflow (
SW) —add_vacuum(managed / blocked / already-done / no-manager) andimport_active_map(discover + save). These are the only two functions inworkflow.py. - Start protection — the protection-status surface and its block reasons.
- Drift — new-segment / removed-segment detection vs the last recorded room
set, including the deep threshold/guard branches and the configured-vs-discovered
exclusion gate (a room in a bucket with
is_configured=Falseis not drift-tracked). Also the C58 read-failure classification: a pass that discovers NO rooms is an unreadable pass, not an empty map — it warns, and leaves every stored counter unchanged rather than striking (or clearing the strikes on) every configured room. - Delete — map deletion teardown and its remove summary.
- Entry wiring (
SD) —run_discovery_passand the manager-side setup helpers reachable without a full boot. - Step-heading keys (
SSK,tests/unit/test_card_sentence_contracts.py) — everySETUP_STEP_IDSmember has asetup.step_<id>key in the card's catalogue. The wizard resolves that key and falls back to the backend'sstep.labelon a miss, which is an English label in every language. Three of the five were keyed and two were not; no adapter ships those two, so nothing was English on screen — which is exactly why nobody would notice the day one started.[SSK-3]narrows to the ids adapters actually declare, read from the adapter sources rather than restated, so a failure there is live rather than forward-looking. That file also carries[OA-*], which belongs to planning:_order_advisorymust keep returning exactly ONE sentence, because the card keys on its presence and renders its own wording — a second sentence would silently render as the first.
How it's tested¶
The manager / manager_with_services fixtures plus test_init_setup.py for
the entry-level wiring. protection.py is pure and unit-tested.
One entry-level behaviour needs the opposite precondition to every test in
test_init_setup.py, so it lives apart in test_init_provider_readiness.py:
the cold-start provider-readiness rule (INKR1TW7). async_at_started fires
immediately when HA is already running, so a config entry set up against a
running hass cannot tell a deferred read from an inline one — that file boots
the entry with hass NOT started, publishes the vacuum's companion entities
only afterwards, and asserts the capability snapshot is repaired rather than
cached.
Known gaps¶
The top-level integration entry file custom_components/eufy_vacuum/__init__.py
(317 stmts, 92%) is the largest remaining gap and is integration-boot
territory: async_setup_entry orchestration (battery-rebaseline service
registration, mapping-tracker position registration, subsystem wiring) only runs
under a full config-entry boot — a different test class than this suite. Note this
is not the setup-package setup/__init__.py shown in the table above, which is a
docstring-only file (0 stmts, 100%).
Within the subsystem package itself, drift.py is 94% (342 of 360 statements,
12 partial branches), up from 85%. That triage — which this section previously
flagged as "directional, not exhaustive" — has now been done line by line, and the
remaining 18 statements split cleanly:
- 13 are still-untested but reachable: 438/450 (
active_map_configured's blank-state and absent-bucket arms), 568 (_drift_history's unattributable bucket formap_id=Noneon a multi-map vacuum), 820-821 (the history-only arm ofcompute_room_drift), 938/956 (the zero-mapreject_roomsflat-list path), 968-980 (the rejection strip loop's junk guards) and 1069-1070 (unreject_rooms' per-map keep bookkeeping). - 5 are DEFENSIVE and deliberately left: 860-861, 1126, 1129-1130, where the
only producer (
rooms/room_discovery.py) already coercesroom_idtointand builds dicts, so only a patched producer reaches them. A test there would encode an assumption about a shape nothing emits.
So the reachable ceiling is 355/360 = 98.6%, and nothing in this module needs a live HA, hardware or network.
DRD-26–DRD-33 closed the other 30. Two are worth reading rather than counting:
DRD-26 pins the stale-key sweep, which is the only bound on drift-history
growth (the module's own comment: it "prevents history from growing unboundedly
across years") — and also pins the deliberate half, that a non-numeric key is
skipped, not deleted, so it leaks without crashing the pass. DRD-27 pins
first_missed_at keeping its ORIGINAL value: it is written only when None, and
without that guard every pass restamps "now", so the field always reads as
just-missed and a room never ages out of the removal threshold.
status.py (96%, missing 128, 263) and workflow.py (91%, missing 159, 164,
170, 204) still leave only a small handful of lines each — a defensive
isinstance bucket guard, a multi-vacuum drift branch, and the
no-manager-available early return. delete.py (95%, missing 163) and
protection.py (96%, missing 42) likewise have essentially no remaining gap.