Files
localthings/tests/test_operational_capability.py
T
Marc Billow cc2c1e5a1f refactor: move samsung_appliance/ into custom_components/localthings/ocf/
Makes the integration fully self-contained for HACS distribution.
Users installing via HACS get everything in one directory; no external
samsung_appliance package needed.

All component imports updated to relative (.ocf.*); all test imports
updated to custom_components.localthings.ocf.*. ocf_root_ca.pem moves
with the package and resolves correctly via Path(__file__).parent.
2026-06-30 16:34:20 -05:00

23 lines
922 B
Python

import time
from custom_components.localthings.ocf.registry.capabilities.operational import OPERATIONAL_STATE
def test_machine_state_maps_samsung_to_ocf():
ms = next(e for e in OPERATIONAL_STATE.entities if e.key == 'machine_state')
assert ms.value_fn('Run') == 'active'
assert ms.value_fn('Pause') == 'pause'
assert ms.value_fn('Ready') == 'idle'
def test_active_when_true_only_when_running():
assert OPERATIONAL_STATE.active_when({'x.com.samsung.da.state': 'Run'}) is True
assert OPERATIONAL_STATE.active_when({'x.com.samsung.da.state': 'Ready'}) is False
def test_project_extrapolates_remaining_time():
state = {}
OPERATIONAL_STATE.on_observation(state, {'x.com.samsung.da.remainingTime': '1:00:00'})
assert 'remaining_anchor' in state
out = OPERATIONAL_STATE.project(state, {'machine_state': 'active', 'completion_minutes': 60})
assert out['completion_minutes'] <= 60