WS: Improve service calling errors (#23840)

* WS: Improve service calling errors

* Docstyle

* Types

* Update text
This commit is contained in:
Paulus Schoutsen 2019-05-14 07:09:11 +02:00 committed by GitHub
parent 0d96095646
commit de1fd5a7fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 8 deletions

View file

@ -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