Do not use get_hub in deCONZ tests (#122706)

pull/122765/head
Robert Svensson 2024-07-29 11:43:04 +02:00 committed by GitHub
parent 5467685bd8
commit 06ee8fdd47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 20 deletions

View File

@ -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