diff --git a/tests/test_client.py b/tests/test_client.py index 21b8836..cba3972 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -67,6 +67,10 @@ DATA = { 'type': 'Bit' }, 'Unexpected': {'type': 'Unexpected'}, + 'String': { + 'type': 'String', + 'option': 'some string' + }, }, 'Course': { "3": { @@ -117,6 +121,15 @@ class ModelInfoTest(unittest.TestCase): self.assertEqual(expected, actual) def test_value_unsupported(self): + data = "{'type': 'Unexpected'}" with self.assertRaisesRegex( - ValueError, 'unsupported value type Unexpected'): + ValueError, + f"unsupported value type 'Unexpected' data: '{data}'"): self.model_info.value('Unexpected') + + def test_value_unsupported_but_data_available(self): + data = "{'type': 'String', 'option': 'some string}'" + with self.assertRaises( + ValueError, + msg=f"unsupported value type 'String' data: '{data}"): + self.model_info.value('String') diff --git a/wideq/client.py b/wideq/client.py index 31e43d0..3f267ea 100644 --- a/wideq/client.py +++ b/wideq/client.py @@ -340,7 +340,8 @@ class ModelInfo(object): ref = d['option'][0] return ReferenceValue(self.data[ref]) else: - raise ValueError("unsupported value type {}".format(d['type'])) + raise ValueError( + f"unsupported value type '{str(d['type'])}' data: '{str(d)}'") def default(self, name): """Get the default value, if it exists, for a given value.