feat: enhance operational capabilities by adding completion_minutes and updating related logic; remove completion_time references
This commit is contained in:
1 parent
7be91b56e8
commit
365a1c4722
8 files changed
+95
-85
No files matched your search
@@ -1,3 +1,5 @@
|
||||
"""Unit tests for operational state capabilities."""
|
||||
|
||||
from custom_components.localthings.registry.capabilities.operational import OPERATIONAL_STATE
|
||||
|
||||
|
||||
@@ -24,18 +26,8 @@ class TestProgressPercentage:
|
||||
assert desc.rep_fn(rep) == 42
|
||||
|
||||
|
||||
class TestCompletionTime:
|
||||
"""Unit tests for completion_time and completion_minutes entities."""
|
||||
|
||||
def test_completion_time_string(self):
|
||||
desc = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_time')
|
||||
rep = {'x.com.samsung.da.remainingTime': '01:25:30'}
|
||||
assert desc.rep_fn(rep) == '01:25:30'
|
||||
|
||||
def test_completion_time_fallback(self):
|
||||
desc = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_time')
|
||||
rep = {'remainingTime': '00:45:00'}
|
||||
assert desc.rep_fn(rep) == '00:45:00'
|
||||
class TestCompletionMinutes:
|
||||
"""Unit tests for completion_minutes entity."""
|
||||
|
||||
def test_completion_minutes_parsing(self):
|
||||
desc = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_minutes')
|
||||
@@ -48,13 +40,26 @@ class TestCompletionTime:
|
||||
rep_exact = {'x.com.samsung.da.remainingTime': '01:30:00'}
|
||||
assert desc.rep_fn(rep_exact) == 90
|
||||
|
||||
def test_completion_time_missing_or_invalid(self):
|
||||
desc_time = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_time')
|
||||
desc_min = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_minutes')
|
||||
def test_completion_minutes_fallback_key(self):
|
||||
desc = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_minutes')
|
||||
rep = {'remainingTime': '00:45:00'}
|
||||
assert desc.rep_fn(rep) == 45
|
||||
|
||||
def test_completion_minutes_stale_finish_gated(self):
|
||||
"""Firmware freezes remainingTime at '00:01:00' when progress reaches 'Finish'.
|
||||
Should return 0 to prevent stuck values."""
|
||||
desc = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_minutes')
|
||||
rep = {
|
||||
'x.com.samsung.da.progress': 'Finish',
|
||||
'x.com.samsung.da.remainingTime': '00:01:00',
|
||||
}
|
||||
assert desc.rep_fn(rep) == 0
|
||||
|
||||
def test_completion_minutes_missing_or_invalid(self):
|
||||
desc = next(e for e in OPERATIONAL_STATE.entities if e.key == 'completion_minutes')
|
||||
|
||||
rep = {}
|
||||
assert desc_time.rep_fn(rep) is None
|
||||
assert desc_min.rep_fn(rep) is None
|
||||
assert desc.rep_fn(rep) is None
|
||||
|
||||
|
||||
class TestDelayFieldFallback:
|
||||
|
||||
Reference in new issue
Block a user