Address review: gate the AddWash master write on a readable mask

The master alarm switch wrote AddWashSet_7/_0 without consulting
_add_wash_mask, so a device reporting a wider mask (AddWashSet_15) or a
non-numeric one had it truncated to three bits -- the write that mask's
own docstring rules out, while the per-moment switches already refused it.

Also corrects the washer_ww6500 golden docstring: the fixture carries no
/oic/d and the test passes no device_types, so the device is typed solely
by the WW consumer prefix in its description. A51 is not a board token,
which makes that the fragile route worth naming.
This commit is contained in:
Marek Tyburec committed 2026-08-19 19:41:13 +02:00
1 parent 6003394cb2
commit 51bce3c8cf
3 files changed
+40 -5

No files matched your search

+6 -3
View File
@@ -390,9 +390,12 @@ def test_registry_reproduces_golden_state_keys_for_washer_dryer_combo():
def test_registry_reproduces_golden_state_keys_for_washer_ww6500():
"""DA_WM_A51_20 front-loader, routed by /oic/d's oic.d.washer rather
than a board token. Reports the AddWash tokens and an empty
/wm/editcourse/vs/0, so its cycle list comes from supportedOptions."""
"""DA_WM_A51_20 front-loader, typed solely by the WW consumer prefix in
its /information/vs/0 description: A51 is not a board token, so with the
description blanked this device resolves to nothing and drops to the
unknown-device fallback. That is the fragile route this test pins.
Reports the AddWash tokens and an empty /wm/editcourse/vs/0, so its cycle
list comes from supportedOptions."""
from tests.conftest import _load_device
resources = _load_device("washer_ww6500")
+22
View File
@@ -86,6 +86,17 @@ class TestAlarmMasterSwitch:
desc = _desc("add_wash_alarm", SwitchDesc)
assert _write(desc, "On", {}) is None
@pytest.mark.parametrize("raw", ["15", "On", "-1"])
def test_refuses_to_write_over_a_mask_it_cannot_read(self, raw):
"""A device reporting a wider mask must not have it truncated to 7.
The master is gated exactly like the per-moment writes, so an
unrecognized mask leaves every AddWash switch read-only."""
desc = _desc("add_wash_alarm", SwitchDesc)
rep = _rep(f"AddWashSet_{raw}")
assert desc.rep_fn(rep) is None
assert _write(desc, "On", rep) is None
assert _write(desc, "Off", rep) is None
class TestAlarmMomentSwitches:
@pytest.mark.parametrize("key,bit", BITS.items())
@@ -197,6 +208,17 @@ class TestAgainstTheWW6500Dump:
"""DA_WM_A51_20_COMMON_WW6500, captured with the alarm off, the course
permitting all three moments and the lamp dark."""
def test_types_only_by_the_description_consumer_prefix(self):
"""A51 is not a board token, so the WW prefix in the description is
the only thing routing this device -- see the golden test's docstring.
Pinned here so the claim can't quietly stop being true."""
from custom_components.localthings.registry.by_type import for_device_by_model
info = _load_device("washer_ww6500")["/information/vs/0"]
model = info["x.com.samsung.da.modelNum"]
assert for_device_by_model(model, info["x.com.samsung.da.description"]).name == "washer"
assert for_device_by_model(model, "") is None
def test_no_unbound_hrefs(self):
resources = _load_device("washer_ww6500")
reg = resolve(resources)