Improve recorder tests to check indices are removed (#125164)

pull/125189/head
Erik Montnemery 2024-09-03 22:56:27 +02:00 committed by GitHub
parent c4cfff4b3f
commit d8382c6de2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -35,6 +35,7 @@ from homeassistant.components.recorder.queries import (
from homeassistant.components.recorder.tasks import EntityIDPostMigrationTask
from homeassistant.components.recorder.util import (
execute_stmt_lambda_element,
get_index_by_name,
session_scope,
)
from homeassistant.core import HomeAssistant
@ -333,6 +334,10 @@ async def test_migrate_events_context_ids(
== migration.EventsContextIDMigration.migration_version
)
# Check the index which will be removed by the migrator no longer exists
with session_scope(hass=hass) as session:
assert get_index_by_name(session, "states", "ix_states_context_id") is None
@pytest.mark.parametrize("enable_migrate_context_ids", [True])
@pytest.mark.usefixtures("db_schema_32")
@ -531,6 +536,10 @@ async def test_migrate_states_context_ids(
== migration.StatesContextIDMigration.migration_version
)
# Check the index which will be removed by the migrator no longer exists
with session_scope(hass=hass) as session:
assert get_index_by_name(session, "states", "ix_states_context_id") is None
@pytest.mark.parametrize("enable_migrate_event_type_ids", [True])
@pytest.mark.usefixtures("db_schema_32")