This commit is contained in:
J. Nick Koston
2023-03-09 15:41:30 -10:00
parent 860b92610b
commit 357da784fa
2 changed files with 1 additions and 30 deletions

View File

@@ -1324,6 +1324,7 @@ def migrate_event_type_ids(instance: Recorder) -> bool:
[
{
"event_id": event_id,
"event_type": None,
"event_type_id": event_type_to_id[event_type],
}
for event_id, event_type in events

View File

@@ -703,51 +703,24 @@ async def test_migrate_event_type_ids(
instance = await async_setup_recorder_instance(hass)
await async_wait_recording_done(hass)
test_uuid = uuid.uuid4()
uuid_hex = test_uuid.hex
def _insert_events():
with session_scope(hass=hass) as session:
session.add_all(
(
Events(
event_type="event_type_one",
event_data=None,
origin_idx=0,
time_fired=None,
time_fired_ts=1677721632.452529,
context_id=uuid_hex,
context_id_bin=None,
context_user_id=None,
context_user_id_bin=None,
context_parent_id=None,
context_parent_id_bin=None,
),
Events(
event_type="event_type_one",
event_data=None,
origin_idx=0,
time_fired=None,
time_fired_ts=1677721632.552529,
context_id=None,
context_id_bin=None,
context_user_id=None,
context_user_id_bin=None,
context_parent_id=None,
context_parent_id_bin=None,
),
Events(
event_type="event_type_two",
event_data=None,
origin_idx=0,
time_fired=None,
time_fired_ts=1677721632.552529,
context_id=None,
context_id_bin=None,
context_user_id=None,
context_user_id_bin=None,
context_parent_id=None,
context_parent_id_bin=None,
),
)
)
@@ -759,9 +732,6 @@ async def test_migrate_event_type_ids(
instance.queue_task(EventTypeIDMigrationTask())
await async_recorder_block_till_done(hass)
def _object_as_dict(obj):
return {c.key: getattr(obj, c.key) for c in inspect(obj).mapper.column_attrs}
def _fetch_migrated_events():
with session_scope(hass=hass) as session:
events = (