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'
|
'type': 'Bit'
|
||||||
},
|
},
|
||||||
'Unexpected': {'type': 'Unexpected'},
|
'Unexpected': {'type': 'Unexpected'},
|
||||||
'String': {
|
'StringOption': {
|
||||||
'type': 'String',
|
'type': 'String',
|
||||||
'option': 'some string'
|
'option': 'some string'
|
||||||
},
|
},
|
||||||
@ -124,12 +124,14 @@ class ModelInfoTest(unittest.TestCase):
|
|||||||
data = "{'type': 'Unexpected'}"
|
data = "{'type': 'Unexpected'}"
|
||||||
with self.assertRaisesRegex(
|
with self.assertRaisesRegex(
|
||||||
ValueError,
|
ValueError,
|
||||||
f"unsupported value type 'Unexpected' data: '{data}'"):
|
f"unsupported value name: 'Unexpected' type: 'Unexpected' "
|
||||||
|
f"data: '{data}'"):
|
||||||
self.model_info.value('Unexpected')
|
self.model_info.value('Unexpected')
|
||||||
|
|
||||||
def test_value_unsupported_but_data_available(self):
|
def test_value_unsupported_but_data_available(self):
|
||||||
data = "{'type': 'String', 'option': 'some string}'"
|
data = "{'type': 'String', 'option': 'some string'}"
|
||||||
with self.assertRaises(
|
with self.assertRaisesRegex(
|
||||||
ValueError,
|
ValueError,
|
||||||
msg=f"unsupported value type 'String' data: '{data}"):
|
f"unsupported value name: 'StringOption'"
|
||||||
self.model_info.value('String')
|
f" type: 'String' data: '{data}"):
|
||||||
|
self.model_info.value('StringOption')
|
||||||
|
@ -341,7 +341,8 @@ class ModelInfo(object):
|
|||||||
return ReferenceValue(self.data[ref])
|
return ReferenceValue(self.data[ref])
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
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):
|
def default(self, name):
|
||||||
"""Get the default value, if it exists, for a given value.
|
"""Get the default value, if it exists, for a given value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user