fridge: fold the three Auto Door Open variant hrefs into one pattern cap (issue #328)
AUTO_DOOR_SINGLE/KIMCHI/WINECELLAR were identical one-line no-entity Capability declarations differing only by href. Replaced with AUTO_DOOR_VARIANT, a pattern cap keyed on href_prefix='/autodoor/' and gated by match_fn (presence of ado.openOptions) rather than the prefix alone, so it only claims the variant-declaration hrefs and not /autodoor/timer/vs/0 -- which doesn't matter in practice anyway, since that href's own exact-href AUTO_DOOR_TIMER cap always wins first. Registry-scoped (refrigerator.py's own pattern_capabilities list), not global ignored.py -- the unknown-device-type fallback that motivates ignored.py's 'exact hrefs only' rule never reaches this registry, so the same constraint doesn't apply. A fourth fridge sub-type reporting this feature at a new href now needs no code change to stay covered.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
`/status/lock/vs/0`'s ado.devicecontrol switch was already modeled
|
||||
(STATUS_LOCK.auto_door_opener); this dump adds the paired voice-feedback
|
||||
toggle, the door-hold timer, and the per-variant capability declaration
|
||||
href -- see fridge.py's AUTO_DOOR_TIMER/AUTO_DOOR_SINGLE comments.
|
||||
href -- see fridge.py's AUTO_DOOR_TIMER/AUTO_DOOR_VARIANT comments.
|
||||
"""
|
||||
|
||||
from custom_components.localthings.registry.adapter import flatten
|
||||
@@ -67,5 +67,8 @@ def test_auto_door_timer_reads_its_own_options():
|
||||
|
||||
def test_auto_door_single_variant_href_bound_with_no_entities():
|
||||
"""/autodoor/single/vs/0 only ever declares openOptions=['Single'] --
|
||||
no paired current/desired field to expose, so it's coverage-only."""
|
||||
assert fridge.AUTO_DOOR_SINGLE.entities == ()
|
||||
no paired current/desired field to expose, so it's coverage-only via
|
||||
the shared AUTO_DOOR_VARIANT pattern cap, not an entry of its own."""
|
||||
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
||||
_reg, resources = _fridge()
|
||||
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/single/vs/0"], resources)
|
||||
|
||||
@@ -51,4 +51,6 @@ def test_auto_door_opener_present():
|
||||
|
||||
|
||||
def test_auto_door_kimchi_variant_href_bound_with_no_entities():
|
||||
assert fridge.AUTO_DOOR_KIMCHI.entities == ()
|
||||
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
||||
_reg, resources = _fridge()
|
||||
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/kimchi/vs/0"], resources)
|
||||
|
||||
@@ -74,5 +74,7 @@ def test_winecellar_pantry_zone_mode_options_and_write():
|
||||
|
||||
|
||||
def test_winecellar_variant_and_info_hrefs_bound_with_no_entities():
|
||||
assert fridge.AUTO_DOOR_WINECELLAR.entities == ()
|
||||
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
||||
assert fridge.WINECELLAR_INFO.entities == ()
|
||||
_reg, resources = _fridge()
|
||||
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/winecellar/vs/0"], resources)
|
||||
|
||||
Reference in New Issue
Block a user