mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 15:20:09 -07:00
Merge pull request #27 from boralyl/bugfix/reference-value
Fixes the ReferenceValue type.
This commit is contained in:
commit
3411ba85e9
@ -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):
|
||||
|
@ -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']))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user