From 06ee8fdd47b5a36f58c6e4bce622dd2e79655cbd Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Mon, 29 Jul 2024 11:43:04 +0200 Subject: [PATCH] Do not use get_hub in deCONZ tests (#122706) --- tests/components/deconz/test_hub.py | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/tests/components/deconz/test_hub.py b/tests/components/deconz/test_hub.py index 43c2dccae93..43c51179337 100644 --- a/tests/components/deconz/test_hub.py +++ b/tests/components/deconz/test_hub.py @@ -9,7 +9,6 @@ from syrupy import SnapshotAssertion from homeassistant.components import ssdp from homeassistant.components.deconz.config_flow import DECONZ_MANUFACTURERURL from homeassistant.components.deconz.const import DOMAIN as DECONZ_DOMAIN -from homeassistant.components.deconz.hub import DeconzHub from homeassistant.components.ssdp import ( ATTR_UPNP_MANUFACTURER_URL, ATTR_UPNP_SERIAL, @@ -71,13 +70,15 @@ async def test_update_address( hass: HomeAssistant, config_entry_setup: MockConfigEntry ) -> None: """Make sure that connection status triggers a dispatcher send.""" - gateway = DeconzHub.get_hub(hass, config_entry_setup) - assert gateway.api.host == "1.2.3.4" + assert config_entry_setup.data["host"] == "1.2.3.4" - with patch( - "homeassistant.components.deconz.async_setup_entry", - return_value=True, - ) as mock_setup_entry: + with ( + patch( + "homeassistant.components.deconz.async_setup_entry", + return_value=True, + ) as mock_setup_entry, + patch("pydeconz.gateway.WSClient") as ws_mock, + ): await hass.config_entries.flow.async_init( DECONZ_DOMAIN, data=ssdp.SsdpServiceInfo( @@ -94,17 +95,6 @@ async def test_update_address( ) await hass.async_block_till_done() - assert gateway.api.host == "2.3.4.5" + assert ws_mock.call_args[0][1] == "2.3.4.5" + assert config_entry_setup.data["host"] == "2.3.4.5" assert len(mock_setup_entry.mock_calls) == 1 - - -async def test_reset_after_successful_setup( - hass: HomeAssistant, config_entry_setup: MockConfigEntry -) -> None: - """Make sure that connection status triggers a dispatcher send.""" - gateway = DeconzHub.get_hub(hass, config_entry_setup) - - result = await gateway.async_reset() - await hass.async_block_till_done() - - assert result is True