Files
localthings/tests/test_dishwasher_capabilities.py
T
Marc Billow e89aa4bab5 Fix transposed Normal/Express 60 dishwasher cycle labels (issue #226)
'83' and '86' were swapped in the dishwasher_cycle catalog. Both the
original DW9000F-class fixture this table was built from and the issue
#226 reporter's board share the identical DeviceType_0812, and the
original fixture's own editCourseList puts the two codes back to back
(positions 4-5) -- a plausible adjacent-pair transcription slip. The
reporter's live confirmation (selecting 'Normal' ran the physical Express
60 program and vice versa) settles which way: '86' is Express 60, '83' is
Normal.

The energy-sensor part of the same issue was already resolved per the
issue thread (the device genuinely doesn't report usage, so the sensor's
removal was correct) -- not touched here.
2026-08-03 19:30:02 +00:00

73 lines
3.0 KiB
Python

"""Tests for dishwasher-specific capabilities.
The shared /course/vs/0 cycle-select machinery (parse_edit_course_list,
cycle_options, cycle_write) is tested in test_laundry_capabilities.py; here we
check the dishwasher wiring and its device-specific options.
"""
from custom_components.localthings.registry.capabilities import dishwasher, laundry
from custom_components.localthings.registry.entities import SwitchDesc
class TestCycleOptions:
def _cycle(self):
return next(e for e in dishwasher.CYCLE_OPTIONS.entities if e.key == "cycle")
def test_cycle_desc_uses_shared_cycle_options(self):
desc = self._cycle()
assert desc.options is laundry.cycle_options
assert desc.translation_key == "dishwasher_cycle"
def test_exists_only_when_edit_course_list_is_live(self):
desc = self._cycle()
assert desc.exists_fn({}, {}) is False
assert desc.exists_fn({}, {"/wm/editcourse/vs/0": {}}) is False
live = {"/wm/editcourse/vs/0": {"x.com.samsung.da.editCourseList": "EditCourseList_0E"}}
assert desc.exists_fn({}, live) is True
def test_cycle_write_uses_raw_code_directly(self):
desc = self._cycle()
rep = {"x.com.samsung.da.options": ["DeviceType_0001", "Course_0E", "GMT_04"]}
path, body = desc.write_fn("90", rep)
assert path == ["course", "vs", "0"]
assert body == {"x.com.samsung.da.options": ["Course_90"]}
def test_normal_and_express_60_labels_are_not_transposed():
"""Issue #226: '83'/'86' were swapped in the shipped catalog -- '86' is
Express 60, '83' is Normal (see dishwasher.py's CYCLE_OPTIONS comment for
how this was confirmed)."""
from custom_components.localthings.catalog import _ENTITY_CATALOG
state = _ENTITY_CATALOG["select"]["dishwasher_cycle"]["state"]
assert state["83"] == "Normal"
assert state["86"] == "Express 60"
class TestDishwasherOptions:
def test_storm_wash_read_and_write(self):
desc = next(
e
for e in dishwasher.CYCLE_OPTIONS.entities
if e.key == "storm_wash" and isinstance(e, SwitchDesc)
)
assert desc.rep_fn is not None
assert desc.rep_fn({"x.com.samsung.da.options": ["StormWashZone_On"]}) is True
assert desc.rep_fn({"x.com.samsung.da.options": ["StormWashZone_Off"]}) is False
assert desc.write_fn is not None
result = desc.write_fn("Off", {"x.com.samsung.da.options": ["StormWashZone_On"]})
assert result is not None
path, body = result
assert path == ["course", "vs", "0"]
assert "StormWashZone_Off" in body["x.com.samsung.da.options"]
def test_auto_release_exists_only_when_field_present(self):
desc = next(
e
for e in dishwasher.CYCLE_OPTIONS.entities
if e.key == "auto_release_dry" and isinstance(e, SwitchDesc)
)
assert desc.exists_fn is not None
assert desc.exists_fn({"x.com.samsung.da.options": []}, {}) is False
assert desc.exists_fn({"x.com.samsung.da.options": ["AutoDoorRelease_On"]}, {}) is True