Skip to content

Commit

Permalink
Do not use get_hub in deCONZ tests (home-assistant#122706)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 authored Jul 29, 2024
1 parent 5467685 commit 06ee8fd
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions tests/components/deconz/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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,
Expand Down Expand Up @@ -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"

with patch(
"homeassistant.components.deconz.async_setup_entry",
return_value=True,
) as mock_setup_entry:
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,
patch("pydeconz.gateway.WSClient") as ws_mock,
):
await hass.config_entries.flow.async_init(
DECONZ_DOMAIN,
data=ssdp.SsdpServiceInfo(
Expand All @@ -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

0 comments on commit 06ee8fd

Please sign in to comment.