Fix history API (#13214)

This commit is contained in:
Paulus Schoutsen 2018-03-14 14:29:51 -07:00 committed by Pascal Vizeli
parent ef7ce5eb1b
commit a9917e7a56
2 changed files with 16 additions and 6 deletions

View file

@ -4,7 +4,7 @@ from datetime import timedelta
import unittest
from unittest.mock import patch, sentinel
from homeassistant.setup import setup_component
from homeassistant.setup import setup_component, async_setup_component
import homeassistant.core as ha
import homeassistant.util.dt as dt_util
from homeassistant.components import history, recorder
@ -481,3 +481,13 @@ class TestComponentHistory(unittest.TestCase):
set_state(therm, 22, attributes={'current_temperature': 21,
'hidden': True})
return zero, four, states
async def test_fetch_period_api(hass, test_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)
response = await client.get(
'/api/history/period/{}'.format(dt_util.utcnow().isoformat()))
assert response.status == 200