WS: Improve service calling errors (#23840)
* WS: Improve service calling errors * Docstyle * Types * Update text
This commit is contained in:
parent
0d96095646
commit
de1fd5a7fa
6 changed files with 68 additions and 8 deletions
|
@ -67,6 +67,30 @@ async def test_call_service_not_found(hass, websocket_client):
|
|||
assert msg['error']['code'] == const.ERR_NOT_FOUND
|
||||
|
||||
|
||||
async def test_call_service_child_not_found(hass, websocket_client):
|
||||
"""Test not reporting not found errors if it's not the called service."""
|
||||
async def serv_handler(call):
|
||||
await hass.services.async_call('non', 'existing')
|
||||
|
||||
hass.services.async_register('domain_test', 'test_service', serv_handler)
|
||||
|
||||
await websocket_client.send_json({
|
||||
'id': 5,
|
||||
'type': 'call_service',
|
||||
'domain': 'domain_test',
|
||||
'service': 'test_service',
|
||||
'service_data': {
|
||||
'hello': 'world'
|
||||
}
|
||||
})
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg['id'] == 5
|
||||
assert msg['type'] == const.TYPE_RESULT
|
||||
assert not msg['success']
|
||||
assert msg['error']['code'] == const.ERR_HOME_ASSISTANT_ERROR
|
||||
|
||||
|
||||
async def test_call_service_error(hass, websocket_client):
|
||||
"""Test call service command with error."""
|
||||
@callback
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue