Fix logbook JSON serialize issue (#13229)

* Fix logbook JSON serialize issue

* Address flakiness

* Lint

* deflake ?

* Deflake 2
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2018-03-15 10:54:22 -07:00
1 parent ee6d6a8859
commit 170b8671b9
4 files changed
+29 -15

No files matched your search

+4 -2
View File
@@ -483,11 +483,13 @@ class TestComponentHistory(unittest.TestCase):
return zero, four, states
async def test_fetch_period_api(hass, test_client):
async def test_fetch_period_api(hass, aiohttp_client):
"""Test the fetch period view for history."""
await hass.async_add_job(init_recorder_component, hass)
await async_setup_component(hass, 'history', {})
client = await test_client(hass.http.app)
await hass.components.recorder.wait_connection_ready()
await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
client = await aiohttp_client(hass.http.app)
response = await client.get(
'/api/history/period/{}'.format(dt_util.utcnow().isoformat()))
assert response.status == 200
+14 -2
View File
@@ -10,8 +10,8 @@ from homeassistant.const import (
EVENT_STATE_CHANGED, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
ATTR_HIDDEN, STATE_NOT_HOME, STATE_ON, STATE_OFF)
import homeassistant.util.dt as dt_util
from homeassistant.components import logbook
from homeassistant.setup import setup_component
from homeassistant.components import logbook, recorder
from homeassistant.setup import setup_component, async_setup_component
from tests.common import (
init_recorder_component, get_test_home_assistant)
@@ -555,3 +555,15 @@ class TestComponentLogbook(unittest.TestCase):
'old_state': state,
'new_state': state,
}, time_fired=event_time_fired)
async def test_logbook_view(hass, aiohttp_client):
"""Test the logbook view."""
await hass.async_add_job(init_recorder_component, hass)
await async_setup_component(hass, 'logbook', {})
await hass.components.recorder.wait_connection_ready()
await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
client = await aiohttp_client(hass.http.app)
response = await client.get(
'/api/logbook/{}'.format(dt_util.utcnow().isoformat()))
assert response.status == 200