Commit c4b46b7
test: add coverage gaps from PR homeassistant-ai#1168 review (Blockers 1/4/5 + Boy-Scout e/f/g)
Addresses kingpanther13's PR homeassistant-ai#1168 review test-coverage findings:
Blocker #1 — DEEP_SEARCH_KEYS scenes:
- Added 'scenes' to the test-helper tuple at tests/src/e2e/tools/test_deep_search.py:14;
every default-call deep_search test had been silently skipping the scenes
bucket because the iteration source didn't include it.
- Updated test_deep_search_all_types to count scenes in the result tally.
- Generalised test_deep_search_limit's count to iterate DEEP_SEARCH_KEYS so
any future bucket addition flows through automatically.
- Added test_deep_search_default_includes_scenes locking the contract that
a default-call response must include the scenes bucket.
Blocker #4 — DELETE blocklist coverage:
- Added test_api_post_blocks_scene_config_delete next to
test_api_post_blocks_scene_config_write. Sandbox exposes only
api_post/api_get (no api_delete), so the test exercises the delete-
flavored attack pattern (empty-body POST) and asserts the path-prefix
blocklist still rejects it.
Blocker #5 — 404 → ENTITY_NOT_FOUND:
- ha_config_get_scene's exception catch now passes entity_id alongside
scene_id so the helper's 404 classifier picks ENTITY_NOT_FOUND instead
of the generic RESOURCE_NOT_FOUND fallback. Scenes are entities, and
agents branching on the not-found code lose the scenes-are-entities
signal otherwise.
- Added TestSceneRestClientErrorMapping with two unit tests:
test_get_scene_404_surfaces_as_entity_not_found locks the 404 path,
test_set_scene_400_surfaces_with_scene_id_context covers Boy-Scout g
(upsert 400 path — highest-likelihood scene failure when an LLM
submits malformed entity state).
Boy-Scout — additional test gaps closed:
- (e) E2E rename scenario: test_scene_rename_decouples_entity_id_from_storage_key
in tests/src/e2e/workflows/scenes/test_lifecycle.py exercises the
full create → get → python_transform → remove path against a scene
whose storage key and entity_id slug diverge. Locks the
_resolve_scene_entity_id contract end-to-end against the no-warning
invariant the BAT validation surfaced as broken before it landed.
- (f) Phase 2.5 registry-augmentation:
TestSceneRegistryAugmentation in tests/src/unit/test_smart_search_scene_phase25.py
with two tests — one locking the alias-on-divergence behaviour, one
verifying that a failing entity-registry list does not break the
scene branch and falls through to storage-id keyed lookup.
- (g) upsert 400 path: covered alongside Blocker #5 in
TestSceneRestClientErrorMapping (one test class for both).
Plus partial-failure coverage for Boy-Scout d (silent failures surfacing,
landed in the previous commit): TestSceneFetchPartialFailure with
test_per_id_failures_surface_partial and a test_no_partial_flag_when_everything_clean
negative case so the 'partial' field doesn't accidentally always-be-set.
ruff + mypy clean; full unit suite passes 1982 tests (was 1976; +6 new
unit tests across the new test classes). E2E tests run in CI only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5c5ac79 commit c4b46b7
6 files changed
Lines changed: 604 additions & 103 deletions
File tree
- src/ha_mcp/tools
- tests/src
- e2e
- tools
- workflows/scenes
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
158 | 166 | | |
159 | 167 | | |
160 | 168 | | |
| |||
0 commit comments