From facf9276268aeda37b24cb6799bda8e6bfb9ec74 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 9 Feb 2024 11:11:05 -0600 Subject: [PATCH] Use async_update_entry in github tests (#110119) needed for #110023 --- tests/components/github/test_config_flow.py | 9 ++++--- tests/components/github/test_diagnostics.py | 5 +++- tests/components/github/test_init.py | 28 +++++++++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/tests/components/github/test_config_flow.py b/tests/components/github/test_config_flow.py index 32388fb65d1..67746d891d1 100644 --- a/tests/components/github/test_config_flow.py +++ b/tests/components/github/test_config_flow.py @@ -260,9 +260,12 @@ async def test_options_flow( mock_setup_entry: None, ) -> None: """Test options flow.""" - mock_config_entry.options = { - CONF_REPOSITORIES: ["homeassistant/core", "homeassistant/architecture"] - } + hass.config_entries.async_update_entry( + mock_config_entry, + options={ + CONF_REPOSITORIES: ["homeassistant/core", "homeassistant/architecture"] + }, + ) mock_config_entry.add_to_hass(hass) await hass.config_entries.async_setup(mock_config_entry.entry_id) diff --git a/tests/components/github/test_diagnostics.py b/tests/components/github/test_diagnostics.py index 4bd7563e743..c358ccc9e6d 100644 --- a/tests/components/github/test_diagnostics.py +++ b/tests/components/github/test_diagnostics.py @@ -25,7 +25,10 @@ async def test_entry_diagnostics( aioclient_mock: AiohttpClientMocker, ) -> None: """Test config entry diagnostics.""" - mock_config_entry.options = {CONF_REPOSITORIES: ["home-assistant/core"]} + hass.config_entries.async_update_entry( + mock_config_entry, + options={CONF_REPOSITORIES: ["home-assistant/core"]}, + ) response_json = json.loads(load_fixture("graphql.json", DOMAIN)) response_json["data"]["repository"]["full_name"] = "home-assistant/core" diff --git a/tests/components/github/test_init.py b/tests/components/github/test_init.py index 612c6579639..f2301056ff8 100644 --- a/tests/components/github/test_init.py +++ b/tests/components/github/test_init.py @@ -21,7 +21,10 @@ async def test_device_registry_cleanup( caplog: pytest.LogCaptureFixture, ) -> None: """Test that we remove untracked repositories from the decvice registry.""" - mock_config_entry.options = {CONF_REPOSITORIES: ["home-assistant/core"]} + hass.config_entries.async_update_entry( + mock_config_entry, + options={CONF_REPOSITORIES: ["home-assistant/core"]}, + ) await setup_github_integration(hass, mock_config_entry, aioclient_mock) devices = dr.async_entries_for_config_entry( @@ -31,7 +34,10 @@ async def test_device_registry_cleanup( assert len(devices) == 1 - mock_config_entry.options = {CONF_REPOSITORIES: []} + hass.config_entries.async_update_entry( + mock_config_entry, + options={CONF_REPOSITORIES: []}, + ) assert await hass.config_entries.async_reload(mock_config_entry.entry_id) await hass.async_block_till_done() @@ -56,8 +62,11 @@ async def test_subscription_setup( aioclient_mock: AiohttpClientMocker, ) -> None: """Test that we setup event subscription.""" - mock_config_entry.options = {CONF_REPOSITORIES: ["home-assistant/core"]} - mock_config_entry.pref_disable_polling = False + hass.config_entries.async_update_entry( + mock_config_entry, + options={CONF_REPOSITORIES: ["home-assistant/core"]}, + pref_disable_polling=False, + ) await setup_github_integration(hass, mock_config_entry, aioclient_mock) assert ( "https://api.github.com/repos/home-assistant/core/events" in x[1] @@ -73,8 +82,11 @@ async def test_subscription_setup_polling_disabled( aioclient_mock: AiohttpClientMocker, ) -> None: """Test that we do not setup event subscription if polling is disabled.""" - mock_config_entry.options = {CONF_REPOSITORIES: ["home-assistant/core"]} - mock_config_entry.pref_disable_polling = True + hass.config_entries.async_update_entry( + mock_config_entry, + options={CONF_REPOSITORIES: ["home-assistant/core"]}, + pref_disable_polling=True, + ) await setup_github_integration(hass, mock_config_entry, aioclient_mock) assert ( "https://api.github.com/repos/home-assistant/core/events" not in x[1] @@ -82,7 +94,9 @@ async def test_subscription_setup_polling_disabled( ) # Prove that we subscribed if the user enabled polling again - mock_config_entry.pref_disable_polling = False + hass.config_entries.async_update_entry( + mock_config_entry, pref_disable_polling=False + ) assert await hass.config_entries.async_reload(mock_config_entry.entry_id) await hass.async_block_till_done() assert (