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

+8 -4
View File
@@ -3,6 +3,9 @@
import asyncio
import datetime
import pytest
import voluptuous as vol
from homeassistant.core import CoreState, State, Context
from homeassistant.setup import async_setup_component
from homeassistant.components.input_datetime import (
@@ -109,10 +112,11 @@ def test_set_invalid(hass):
dt_obj = datetime.datetime(2017, 9, 7, 19, 46)
time_portion = dt_obj.time()
yield from hass.services.async_call('input_datetime', 'set_datetime', {
'entity_id': 'test_date',
'time': time_portion
})
with pytest.raises(vol.Invalid):
yield from hass.services.async_call('input_datetime', 'set_datetime', {
'entity_id': 'test_date',
'time': time_portion
})
yield from hass.async_block_till_done()
state = hass.states.get(entity_id)