mirror of
https://github.com/elisspace/core.git
synced 2026-10-01 06:49:55 +00:00
Fix history using pre v25 queries during v26 migration (#71294)
This commit is contained in:
@@ -628,7 +628,7 @@ async def test_state_changes_during_period_query_during_migration_to_schema_25(
|
||||
conn.execute(text("drop table state_attributes;"))
|
||||
conn.commit()
|
||||
|
||||
with patch.object(instance, "migration_in_progress", True):
|
||||
with patch.object(instance, "schema_version", 24):
|
||||
no_attributes = True
|
||||
hist = history.state_changes_during_period(
|
||||
hass, start, end, entity_id, no_attributes, include_start_time_state=False
|
||||
@@ -674,7 +674,7 @@ async def test_get_states_query_during_migration_to_schema_25(
|
||||
conn.execute(text("drop table state_attributes;"))
|
||||
conn.commit()
|
||||
|
||||
with patch.object(instance, "migration_in_progress", True):
|
||||
with patch.object(instance, "schema_version", 24):
|
||||
no_attributes = True
|
||||
hist = await _async_get_states(
|
||||
hass, end, [entity_id], no_attributes=no_attributes
|
||||
@@ -723,7 +723,7 @@ async def test_get_states_query_during_migration_to_schema_25_multiple_entities(
|
||||
conn.execute(text("drop table state_attributes;"))
|
||||
conn.commit()
|
||||
|
||||
with patch.object(instance, "migration_in_progress", True):
|
||||
with patch.object(instance, "schema_version", 24):
|
||||
no_attributes = True
|
||||
hist = await _async_get_states(
|
||||
hass, end, entity_ids, no_attributes=no_attributes
|
||||
|
||||
@@ -31,6 +31,7 @@ from homeassistant.components.recorder import (
|
||||
)
|
||||
from homeassistant.components.recorder.const import DATA_INSTANCE
|
||||
from homeassistant.components.recorder.models import (
|
||||
SCHEMA_VERSION,
|
||||
Events,
|
||||
RecorderRuns,
|
||||
StateAttributes,
|
||||
@@ -438,6 +439,12 @@ def _state_empty_context(hass, entity_id):
|
||||
return state
|
||||
|
||||
|
||||
def test_setup_without_migration(hass_recorder):
|
||||
"""Verify the schema version without a migration."""
|
||||
hass = hass_recorder()
|
||||
assert recorder.get_instance(hass).schema_version == SCHEMA_VERSION
|
||||
|
||||
|
||||
# pylint: disable=redefined-outer-name,invalid-name
|
||||
def test_saving_state_include_domains(hass_recorder):
|
||||
"""Test saving and restoring a state."""
|
||||
|
||||
@@ -22,7 +22,11 @@ from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import persistent_notification as pn, recorder
|
||||
from homeassistant.components.recorder import migration, models
|
||||
from homeassistant.components.recorder.const import DATA_INSTANCE
|
||||
from homeassistant.components.recorder.models import RecorderRuns, States
|
||||
from homeassistant.components.recorder.models import (
|
||||
SCHEMA_VERSION,
|
||||
RecorderRuns,
|
||||
States,
|
||||
)
|
||||
from homeassistant.components.recorder.util import session_scope
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
@@ -79,6 +83,7 @@ async def test_migration_in_progress(hass):
|
||||
await async_wait_recording_done(hass)
|
||||
|
||||
assert recorder.util.async_migration_in_progress(hass) is False
|
||||
assert recorder.get_instance(hass).schema_version == SCHEMA_VERSION
|
||||
|
||||
|
||||
async def test_database_migration_failed(hass):
|
||||
|
||||
Reference in New Issue
Block a user