Forbid float NaN in JSON (#18757)
This commit is contained in:
parent
5c3a4e3d10
commit
a2386f871d
4 changed files with 28 additions and 7 deletions
|
@ -300,3 +300,19 @@ async def test_states_filters_visible(hass, hass_admin_user, websocket_client):
|
|||
|
||||
assert len(msg['result']) == 1
|
||||
assert msg['result'][0]['entity_id'] == 'test.entity'
|
||||
|
||||
|
||||
async def test_get_states_not_allows_nan(hass, websocket_client):
|
||||
"""Test get_states command not allows NaN floats."""
|
||||
hass.states.async_set('greeting.hello', 'world', {
|
||||
'hello': float("NaN")
|
||||
})
|
||||
|
||||
await websocket_client.send_json({
|
||||
'id': 5,
|
||||
'type': commands.TYPE_GET_STATES,
|
||||
})
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert not msg['success']
|
||||
assert msg['error']['code'] == const.ERR_UNKNOWN_ERROR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue