From 5c60ff19e92affc5517a436d614ad6cfef389d92 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 12 Feb 2024 14:38:38 -0600 Subject: [PATCH] Migrate plex to use async_update_entry to alter config entries (#110405) --- tests/components/plex/test_config_flow.py | 3 ++- tests/components/plex/test_init.py | 8 +++++--- tests/components/plex/test_server.py | 9 ++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/components/plex/test_config_flow.py b/tests/components/plex/test_config_flow.py index 47d70727890..b2a4f3c23a5 100644 --- a/tests/components/plex/test_config_flow.py +++ b/tests/components/plex/test_config_flow.py @@ -442,7 +442,8 @@ async def test_option_flow_new_users_available( OPTIONS_OWNER_ONLY[Platform.MEDIA_PLAYER][CONF_MONITORED_USERS] = { "User 1": {"enabled": True} } - entry.options = OPTIONS_OWNER_ONLY + entry.add_to_hass(hass) + hass.config_entries.async_update_entry(entry, options=OPTIONS_OWNER_ONLY) mock_plex_server = await setup_plex_server(config_entry=entry) await hass.async_block_till_done() diff --git a/tests/components/plex/test_init.py b/tests/components/plex/test_init.py index e12759b8a1f..47bdc472b2b 100644 --- a/tests/components/plex/test_init.py +++ b/tests/components/plex/test_init.py @@ -76,7 +76,8 @@ async def test_setup_with_insecure_config_entry( """Test setup component with config.""" INSECURE_DATA = copy.deepcopy(DEFAULT_DATA) INSECURE_DATA[const.PLEX_SERVER_CONFIG][CONF_VERIFY_SSL] = False - entry.data = INSECURE_DATA + entry.add_to_hass(hass) + hass.config_entries.async_update_entry(entry, data=INSECURE_DATA) await setup_plex_server(config_entry=entry) @@ -268,11 +269,12 @@ async def test_setup_when_certificate_changed( assert old_entry.data[const.PLEX_SERVER_CONFIG][CONF_URL] == new_url -async def test_tokenless_server(entry, setup_plex_server) -> None: +async def test_tokenless_server(hass, entry, setup_plex_server) -> None: """Test setup with a server with token auth disabled.""" TOKENLESS_DATA = copy.deepcopy(DEFAULT_DATA) TOKENLESS_DATA[const.PLEX_SERVER_CONFIG].pop(CONF_TOKEN, None) - entry.data = TOKENLESS_DATA + entry.add_to_hass(hass) + hass.config_entries.async_update_entry(entry, data=TOKENLESS_DATA) await setup_plex_server(config_entry=entry) assert entry.state is ConfigEntryState.LOADED diff --git a/tests/components/plex/test_server.py b/tests/components/plex/test_server.py index 511025988ed..64abe27b16b 100644 --- a/tests/components/plex/test_server.py +++ b/tests/components/plex/test_server.py @@ -28,7 +28,8 @@ async def test_new_users_available( MONITORED_USERS = {"User 1": {"enabled": True}} OPTIONS_WITH_USERS = copy.deepcopy(DEFAULT_OPTIONS) OPTIONS_WITH_USERS[Platform.MEDIA_PLAYER][CONF_MONITORED_USERS] = MONITORED_USERS - entry.options = OPTIONS_WITH_USERS + entry.add_to_hass(hass) + hass.config_entries.async_update_entry(entry, options=OPTIONS_WITH_USERS) mock_plex_server = await setup_plex_server(config_entry=entry) @@ -55,7 +56,8 @@ async def test_new_ignored_users_available( OPTIONS_WITH_USERS = copy.deepcopy(DEFAULT_OPTIONS) OPTIONS_WITH_USERS[Platform.MEDIA_PLAYER][CONF_MONITORED_USERS] = MONITORED_USERS OPTIONS_WITH_USERS[Platform.MEDIA_PLAYER][CONF_IGNORE_NEW_SHARED_USERS] = True - entry.options = OPTIONS_WITH_USERS + entry.add_to_hass(hass) + hass.config_entries.async_update_entry(entry, options=OPTIONS_WITH_USERS) mock_plex_server = await setup_plex_server(config_entry=entry) @@ -167,7 +169,8 @@ async def test_ignore_plex_web_client( """Test option to ignore Plex Web clients.""" OPTIONS = copy.deepcopy(DEFAULT_OPTIONS) OPTIONS[Platform.MEDIA_PLAYER][CONF_IGNORE_PLEX_WEB_CLIENTS] = True - entry.options = OPTIONS + entry.add_to_hass(hass) + hass.config_entries.async_update_entry(entry, options=OPTIONS) mock_plex_server = await setup_plex_server( config_entry=entry, client_type="plexweb", disable_clients=True