mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Separate recorder test fixtures disabling context id migration (#125324)
* Separate recorder test fixtures disabling context id migration * Fix test
This commit is contained in:
parent
d88487e30b
commit
2a1df2063d
@ -118,7 +118,7 @@ def db_schema_32():
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.parametrize("enable_migrate_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_event_context_ids", [True])
|
||||
@pytest.mark.usefixtures("db_schema_32")
|
||||
async def test_migrate_events_context_ids(
|
||||
hass: HomeAssistant, recorder_mock: Recorder
|
||||
@ -338,7 +338,7 @@ async def test_migrate_events_context_ids(
|
||||
assert get_index_by_name(session, "events", "ix_events_context_id") is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("enable_migrate_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_state_context_ids", [True])
|
||||
@pytest.mark.usefixtures("db_schema_32")
|
||||
async def test_migrate_states_context_ids(
|
||||
hass: HomeAssistant, recorder_mock: Recorder
|
||||
|
@ -72,7 +72,7 @@ def _create_engine_test(*args, **kwargs):
|
||||
return engine
|
||||
|
||||
|
||||
@pytest.mark.parametrize("enable_migrate_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_state_context_ids", [True])
|
||||
@pytest.mark.parametrize("persistent_database", [True])
|
||||
@pytest.mark.usefixtures("hass_storage") # Prevent test hass from writing to storage
|
||||
async def test_migration_changes_prevent_trying_to_migrate_again(
|
||||
@ -173,4 +173,6 @@ async def test_migration_changes_prevent_trying_to_migrate_again(
|
||||
await hass.async_stop()
|
||||
|
||||
for task in tasks:
|
||||
assert not isinstance(task, MigrationTask)
|
||||
if not isinstance(task, MigrationTask):
|
||||
continue
|
||||
assert not isinstance(task.migrator, migration.StatesContextIDMigration)
|
||||
|
@ -60,7 +60,8 @@ def _create_engine_test(schema_module: str) -> Callable:
|
||||
return _create_engine_test
|
||||
|
||||
|
||||
@pytest.mark.parametrize("enable_migrate_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_event_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_state_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_event_type_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_entity_ids", [True])
|
||||
@pytest.mark.parametrize("persistent_database", [True])
|
||||
|
@ -1293,11 +1293,21 @@ def enable_nightly_purge() -> bool:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def enable_migrate_context_ids() -> bool:
|
||||
def enable_migrate_event_context_ids() -> bool:
|
||||
"""Fixture to control enabling of recorder's context id migration.
|
||||
|
||||
To enable context id migration, tests can be marked with:
|
||||
@pytest.mark.parametrize("enable_migrate_context_ids", [True])
|
||||
@pytest.mark.parametrize("enable_migrate_event_context_ids", [True])
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def enable_migrate_state_context_ids() -> bool:
|
||||
"""Fixture to control enabling of recorder's context id migration.
|
||||
|
||||
To enable context id migration, tests can be marked with:
|
||||
@pytest.mark.parametrize("enable_migrate_state_context_ids", [True])
|
||||
"""
|
||||
return False
|
||||
|
||||
@ -1465,7 +1475,8 @@ async def async_test_recorder(
|
||||
enable_statistics: bool,
|
||||
enable_missing_statistics: bool,
|
||||
enable_schema_validation: bool,
|
||||
enable_migrate_context_ids: bool,
|
||||
enable_migrate_event_context_ids: bool,
|
||||
enable_migrate_state_context_ids: bool,
|
||||
enable_migrate_event_type_ids: bool,
|
||||
enable_migrate_entity_ids: bool,
|
||||
enable_migrate_event_ids: bool,
|
||||
@ -1527,12 +1538,12 @@ async def async_test_recorder(
|
||||
)
|
||||
migrate_states_context_ids = (
|
||||
migration.StatesContextIDMigration.migrate_data
|
||||
if enable_migrate_context_ids
|
||||
if enable_migrate_state_context_ids
|
||||
else None
|
||||
)
|
||||
migrate_events_context_ids = (
|
||||
migration.EventsContextIDMigration.migrate_data
|
||||
if enable_migrate_context_ids
|
||||
if enable_migrate_event_context_ids
|
||||
else None
|
||||
)
|
||||
migrate_event_type_ids = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user