diff --git a/tests/test_client.py b/tests/test_client.py index 5d10eb0..21b8836 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -68,6 +68,18 @@ DATA = { }, 'Unexpected': {'type': 'Unexpected'}, }, + 'Course': { + "3": { + "_comment": "Normal", + "courseType": "Course", + "id": 3, + "name": "@WM_DRY27_COURSE_NORMAL_W", + "script": "", + "controlEnable": True, + "freshcareEnable": True, + "imgIndex": 61, + }, + }, } @@ -101,7 +113,7 @@ class ModelInfoTest(unittest.TestCase): def test_value_reference(self): actual = self.model_info.value('Course') - expected = ReferenceValue('Course') + expected = ReferenceValue(DATA['Course']) self.assertEqual(expected, actual) def test_value_unsupported(self): diff --git a/tests/test_simple.py b/tests/test_core.py similarity index 100% rename from tests/test_simple.py rename to tests/test_core.py diff --git a/wideq/client.py b/wideq/client.py index 4b1be67..2a5fa66 100644 --- a/wideq/client.py +++ b/wideq/client.py @@ -296,6 +296,8 @@ class DeviceInfo(object): BitValue = namedtuple('BitValue', ['options']) EnumValue = namedtuple('EnumValue', ['options']) RangeValue = namedtuple('RangeValue', ['min', 'max', 'step']) +#: This is a value that is a reference to another key in the data that is at +#: the same level as the `Value` key. ReferenceValue = namedtuple('ReferenceValue', ['reference']) @@ -326,7 +328,8 @@ class ModelInfo(object): bit_values = {opt['startbit']: opt['value'] for opt in d['option']} return BitValue(bit_values) elif d['type'].lower() == 'reference': - return ReferenceValue(d['option'][0]) + ref = d['option'][0] + return ReferenceValue(self.data[ref]) else: raise ValueError("unsupported value type {}".format(d['type']))