Improve bad JSON data reporting (#47932)
* Improve bad data reporting * Fix tests Co-authored-by: Erik <erik@montnemery.com>
This commit is contained in:
parent
9ec4c07753
commit
7fe3c472e9
3 changed files with 28 additions and 10 deletions
|
@ -67,7 +67,7 @@ async def test_pending_msg_peak(hass, mock_low_peak, hass_ws_client, caplog):
|
|||
|
||||
|
||||
async def test_non_json_message(hass, websocket_client, caplog):
|
||||
"""Test trying to serialze non JSON objects."""
|
||||
"""Test trying to serialize non JSON objects."""
|
||||
bad_data = object()
|
||||
hass.states.async_set("test_domain.entity", "testing", {"bad": bad_data})
|
||||
await websocket_client.send_json({"id": 5, "type": "get_states"})
|
||||
|
@ -77,6 +77,6 @@ async def test_non_json_message(hass, websocket_client, caplog):
|
|||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert not msg["success"]
|
||||
assert (
|
||||
f"Unable to serialize to JSON. Bad data found at $.result[0](state: test_domain.entity).attributes.bad={bad_data}(<class 'object'>"
|
||||
f"Unable to serialize to JSON. Bad data found at $.result[0](State: test_domain.entity).attributes.bad={bad_data}(<class 'object'>"
|
||||
in caplog.text
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue