From 9c82df4b983eb745fead8bd7e9e6ad4568bf438b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 13 Jan 2024 16:01:18 -1000 Subject: [PATCH] Fix duplicate config entry additions in tests (#107984) zha and plex still add the same config entry multiple times but they are going to need seperate PRs as they have more complex logic --- tests/components/anova/test_init.py | 1 - tests/components/august/test_sensor.py | 3 +-- tests/components/efergy/__init__.py | 1 - tests/components/google/test_calendar.py | 1 - tests/components/kraken/test_sensor.py | 1 - tests/components/ruckus_unleashed/test_device_tracker.py | 1 - tests/components/yeelight/test_light.py | 3 +++ 7 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/components/anova/test_init.py b/tests/components/anova/test_init.py index cbd7231f366..631a69e103b 100644 --- a/tests/components/anova/test_init.py +++ b/tests/components/anova/test_init.py @@ -26,7 +26,6 @@ async def test_wrong_login( ) -> None: """Test for setup failure if connection to Anova is missing.""" entry = create_entry(hass) - entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) assert entry.state is ConfigEntryState.SETUP_ERROR diff --git a/tests/components/august/test_sensor.py b/tests/components/august/test_sensor.py index d71d22064fc..f2ea0066345 100644 --- a/tests/components/august/test_sensor.py +++ b/tests/components/august/test_sensor.py @@ -351,8 +351,7 @@ async def test_restored_state( ], ) - august_entry = await _create_august_with_devices(hass, [lock_one]) - august_entry.add_to_hass(hass) + await _create_august_with_devices(hass, [lock_one]) await hass.async_block_till_done() diff --git a/tests/components/efergy/__init__.py b/tests/components/efergy/__init__.py index 5d77acc6838..3780bcb5494 100644 --- a/tests/components/efergy/__init__.py +++ b/tests/components/efergy/__init__.py @@ -40,7 +40,6 @@ async def init_integration( """Set up the Efergy integration in Home Assistant.""" entry = create_entry(hass, token=token) await mock_responses(hass, aioclient_mock, token=token, error=error) - entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/google/test_calendar.py b/tests/components/google/test_calendar.py index d1cc41e166a..55a9f814a63 100644 --- a/tests/components/google/test_calendar.py +++ b/tests/components/google/test_calendar.py @@ -571,7 +571,6 @@ async def test_scan_calendar_error( config_entry, ) -> None: """Test that the calendar update handles a server error.""" - config_entry.add_to_hass(hass) mock_calendars_list({}, exc=ClientError()) assert await component_setup() diff --git a/tests/components/kraken/test_sensor.py b/tests/components/kraken/test_sensor.py index 3ba351a4225..791b70c1283 100644 --- a/tests/components/kraken/test_sensor.py +++ b/tests/components/kraken/test_sensor.py @@ -162,7 +162,6 @@ async def test_sensors_available_after_restart( manufacturer="Kraken.com", entry_type=dr.DeviceEntryType.SERVICE, ) - entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) diff --git a/tests/components/ruckus_unleashed/test_device_tracker.py b/tests/components/ruckus_unleashed/test_device_tracker.py index 403ea7d0ca7..cda3836a0a4 100644 --- a/tests/components/ruckus_unleashed/test_device_tracker.py +++ b/tests/components/ruckus_unleashed/test_device_tracker.py @@ -98,7 +98,6 @@ async def test_restoring_clients(hass: HomeAssistant) -> None: ) with RuckusAjaxApiPatchContext(active_clients={}): - entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/yeelight/test_light.py b/tests/components/yeelight/test_light.py index 441ec202b28..da907fdee33 100644 --- a/tests/components/yeelight/test_light.py +++ b/tests/components/yeelight/test_light.py @@ -826,6 +826,9 @@ async def test_device_types( # nightlight as a setting of the main entity if nightlight_mode_properties is not None: mocked_bulb.last_properties["active_mode"] = True + config_entry = MockConfigEntry( + domain=DOMAIN, data={**CONFIG_ENTRY_DATA, CONF_NIGHTLIGHT_SWITCH: False} + ) config_entry.add_to_hass(hass) await _async_setup(config_entry) state = hass.states.get(entity_id)