mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-29 13:30:26 -07:00
When ModelInfo contains yet unknown values, also report the name
Then we at least have some idea (hopefully) what kind of data we are going to ignore. See issue #62.
This commit is contained in:
parent
cc3d60f882
commit
72040db991
@ -67,7 +67,7 @@ DATA = {
|
||||
'type': 'Bit'
|
||||
},
|
||||
'Unexpected': {'type': 'Unexpected'},
|
||||
'String': {
|
||||
'StringOption': {
|
||||
'type': 'String',
|
||||
'option': 'some string'
|
||||
},
|
||||
@ -124,12 +124,14 @@ class ModelInfoTest(unittest.TestCase):
|
||||
data = "{'type': 'Unexpected'}"
|
||||
with self.assertRaisesRegex(
|
||||
ValueError,
|
||||
f"unsupported value type 'Unexpected' data: '{data}'"):
|
||||
f"unsupported value name: 'Unexpected' type: 'Unexpected' "
|
||||
f"data: '{data}'"):
|
||||
self.model_info.value('Unexpected')
|
||||
|
||||
def test_value_unsupported_but_data_available(self):
|
||||
data = "{'type': 'String', 'option': 'some string}'"
|
||||
with self.assertRaises(
|
||||
data = "{'type': 'String', 'option': 'some string'}"
|
||||
with self.assertRaisesRegex(
|
||||
ValueError,
|
||||
msg=f"unsupported value type 'String' data: '{data}"):
|
||||
self.model_info.value('String')
|
||||
f"unsupported value name: 'StringOption'"
|
||||
f" type: 'String' data: '{data}"):
|
||||
self.model_info.value('StringOption')
|
||||
|
@ -341,7 +341,8 @@ class ModelInfo(object):
|
||||
return ReferenceValue(self.data[ref])
|
||||
else:
|
||||
raise ValueError(
|
||||
f"unsupported value type '{str(d['type'])}' data: '{str(d)}'")
|
||||
f"unsupported value name: '{name}'"
|
||||
f" type: '{str(d['type'])}' data: '{str(d)}'")
|
||||
|
||||
def default(self, name):
|
||||
"""Get the default value, if it exists, for a given value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user