Switch history tests to pytest (#42318)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Matthew Donoughe 2021-03-17 10:32:44 -04:00 committed by GitHub
parent 6a24ec7a30
commit 9011a54e7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 711 additions and 699 deletions

View file

@ -0,0 +1,49 @@
"""Fixtures for history tests."""
import pytest
from homeassistant.components import history
from homeassistant.components.recorder.const import DATA_INSTANCE
from homeassistant.setup import setup_component
from tests.common import get_test_home_assistant, init_recorder_component
@pytest.fixture
def hass_recorder():
"""Home Assistant fixture with in-memory recorder."""
hass = get_test_home_assistant()
def setup_recorder(config=None):
"""Set up with params."""
init_recorder_component(hass, config)
hass.start()
hass.block_till_done()
hass.data[DATA_INSTANCE].block_till_done()
return hass
yield setup_recorder
hass.stop()
@pytest.fixture
def hass_history(hass_recorder):
"""Home Assistant fixture with history."""
hass = hass_recorder()
config = history.CONFIG_SCHEMA(
{
history.DOMAIN: {
history.CONF_INCLUDE: {
history.CONF_DOMAINS: ["media_player"],
history.CONF_ENTITIES: ["thermostat.test"],
},
history.CONF_EXCLUDE: {
history.CONF_DOMAINS: ["thermostat"],
history.CONF_ENTITIES: ["media_player.test"],
},
}
}
)
assert setup_component(hass, history.DOMAIN, config)
yield hass

File diff suppressed because it is too large Load diff