From c3d919238426a549b666bcfb893982d8998dd16b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 12 Feb 2024 14:24:45 -0600 Subject: [PATCH] Migrate smartthings to use async_update_entry to alter config entries (#110403) --- tests/components/smartthings/test_init.py | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/components/smartthings/test_init.py b/tests/components/smartthings/test_init.py index 0630ffd8392..ec2ec3abe19 100644 --- a/tests/components/smartthings/test_init.py +++ b/tests/components/smartthings/test_init.py @@ -32,8 +32,8 @@ async def test_migration_creates_new_flow( ) -> None: """Test migration deletes app and creates new flow.""" - config_entry.version = 1 config_entry.add_to_hass(hass) + hass.config_entries.async_update_entry(config_entry, version=1) await smartthings.async_migrate_entry(hass, config_entry) await hass.async_block_till_done() @@ -409,6 +409,7 @@ async def test_broker_regenerates_token(hass: HomeAssistant, config_entry) -> No token = Mock(OAuthToken) token.refresh_token = str(uuid4()) stored_action = None + config_entry.add_to_hass(hass) def async_track_time_interval(hass, action, interval): nonlocal stored_action @@ -455,10 +456,14 @@ async def test_event_handler_dispatches_updated_devices( data={"codeId": "1"}, ) request = event_request_factory(device_ids=device_ids, events=[event]) - config_entry.data = { - **config_entry.data, - CONF_INSTALLED_APP_ID: request.installed_app_id, - } + config_entry.add_to_hass(hass) + hass.config_entries.async_update_entry( + config_entry, + data={ + **config_entry.data, + CONF_INSTALLED_APP_ID: request.installed_app_id, + }, + ) called = False def signal(ids): @@ -520,10 +525,14 @@ async def test_event_handler_fires_button_events( device.device_id, capability="button", attribute="button", value="pushed" ) request = event_request_factory(events=[event]) - config_entry.data = { - **config_entry.data, - CONF_INSTALLED_APP_ID: request.installed_app_id, - } + config_entry.add_to_hass(hass) + hass.config_entries.async_update_entry( + config_entry, + data={ + **config_entry.data, + CONF_INSTALLED_APP_ID: request.installed_app_id, + }, + ) called = False def handler(evt):