RFC: Call services directly (#18720)

* Call services directly

* Simplify

* Type

* Lint

* Update name

* Fix tests

* Catch exceptions in HTTP view

* Lint

* Handle ServiceNotFound in API endpoints that call services

* Type

* Don't crash recorder on non-JSON serializable objects
This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2018-11-30 21:28:35 +01:00
1 parent 53cbb28926
commit df21dd21f2
30 files changed
+312 -186

No files matched your search

+5 -4
View File
@@ -3,6 +3,7 @@ import asyncio
from unittest import mock
import pytest
import voluptuous as vol
from homeassistant.setup import async_setup_component
from homeassistant.components.wake_on_lan import (
@@ -34,10 +35,10 @@ def test_send_magic_packet(hass, caplog, mock_wakeonlan):
assert mock_wakeonlan.mock_calls[-1][1][0] == mac
assert mock_wakeonlan.mock_calls[-1][2]['ip_address'] == bc_ip
yield from hass.services.async_call(
DOMAIN, SERVICE_SEND_MAGIC_PACKET,
{"broadcast_address": bc_ip}, blocking=True)
assert 'ERROR' in caplog.text
with pytest.raises(vol.Invalid):
yield from hass.services.async_call(
DOMAIN, SERVICE_SEND_MAGIC_PACKET,
{"broadcast_address": bc_ip}, blocking=True)
assert len(mock_wakeonlan.mock_calls) == 1
yield from hass.services.async_call(