Fix history api with no constraints (#36979)

This commit is contained in:
J. Nick Koston 2020-06-22 10:32:46 -05:00 committed by GitHub
parent 7e696f19d3
commit e19c97af7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -423,7 +423,7 @@ class HistoryPeriodView(HomeAssistantView):
self, request: web.Request, datetime: Optional[str] = None
) -> web.Response:
"""Return history over a period of time."""
datetime_ = None
if datetime:
datetime_ = dt_util.parse_datetime(datetime)

View File

@ -768,6 +768,16 @@ async def test_fetch_period_api_with_minimal_response(hass, hass_client):
assert response.status == 200
async def test_fetch_period_api_with_no_timestamp(hass, hass_client):
"""Test the fetch period view for history with no timestamp."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(hass, "history", {})
await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
client = await hass_client()
response = await client.get("/api/history/period")
assert response.status == 200
async def test_fetch_period_api_with_include_order(hass, hass_client):
"""Test the fetch period view for history."""
await hass.async_add_executor_job(init_recorder_component, hass)