Files
localthings/tests/test_laundry_writes.py
T
Marc Billow b67e0e5cf5 Rename ocf/ to registry/, it's a capability registry now
The DTLS/CoAP transport code that made "ocf" an accurate name moved out to
the smartthings-local package. What's left here (capability.py, entities.py,
discovery.py, adapter.py, identity.py, capabilities/, by_type/, plus the
/device/0 batch parser) is entirely the device capability registry, so name
the package for what it does.

Flattened the redundant ocf/registry/ nesting into a single top-level
registry/ package and updated every import across the platform modules and
test suite accordingly. Verified: full test suite (80/80) passes, and the
Docker dev container reconnects to both live appliances and rediscovers
their entities cleanly after the rename.
2026-07-07 22:54:57 -05:00

59 lines
1.9 KiB
Python

"""Write-handler unit tests for laundry-family capabilities."""
from custom_components.localthings.registry.capabilities import laundry
from custom_components.localthings.registry.capabilities.operational import OPERATIONAL_STATE
def test_start_button_writes_run():
btn = next(e for e in OPERATIONAL_STATE.entities if e.key == 'start')
assert btn.write_fn('Run', {}) == (
['operational', 'state', 'vs', '0'],
{'x.com.samsung.da.state': 'Run'},
)
def test_pause_button_writes_pause():
btn = next(e for e in OPERATIONAL_STATE.entities if e.key == 'pause')
assert btn.write_fn('Pause', {}) == (
['operational', 'state', 'vs', '0'],
{'x.com.samsung.da.state': 'Pause'},
)
def test_stop_button_writes_ready():
btn = next(e for e in OPERATIONAL_STATE.entities if e.key == 'stop')
assert btn.write_fn('Ready', {}) == (
['operational', 'state', 'vs', '0'],
{'x.com.samsung.da.state': 'Ready'},
)
def test_sound_mode_write_valid():
desc = next(e for e in laundry.SOUND_MODE.entities if e.key == 'sound_mode')
assert desc.write_fn('mute', {}) == (
['settings', 'sound', 'mode', 'vs', '0'],
{'mode': 'mute'},
)
assert desc.write_fn('invalid', {}) is None
def test_led_brightness_write_valid():
desc = next(e for e in laundry.DOOR_LED.entities if e.key == 'led_brightness')
assert desc.write_fn('Low', {}) == (
['doorled', 'light', 'vs', '0'],
{'setBrightness': 'Low'},
)
assert desc.write_fn('Medium', {}) is None
def test_led_night_light_write_valid():
desc = next(e for e in laundry.DOOR_LED.entities if e.key == 'led_night_light')
assert desc.write_fn('On', {}) == (
['doorled', 'light', 'vs', '0'],
{'setNightLight': 'On'},
)
assert desc.write_fn('Off', {}) == (
['doorled', 'light', 'vs', '0'],
{'setNightLight': 'Off'},
)
assert desc.write_fn('invalid', {}) is None