mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Adjust freebox tests which create devices (#98190)
This commit is contained in:
parent
52183d64ae
commit
983ebeff80
@ -3,6 +3,7 @@ from unittest.mock import AsyncMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -27,9 +28,10 @@ def mock_path():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_device_registry_devices(device_registry):
|
def mock_device_registry_devices(hass: HomeAssistant, device_registry):
|
||||||
"""Create device registry devices so the device tracker entities are enabled."""
|
"""Create device registry devices so the device tracker entities are enabled."""
|
||||||
config_entry = MockConfigEntry(domain="something_else")
|
config_entry = MockConfigEntry(domain="something_else")
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
for idx, device in enumerate(
|
for idx, device in enumerate(
|
||||||
(
|
(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""Tests for the Freebox config flow."""
|
"""Tests for the Freebox config flow."""
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import ANY, Mock, patch
|
||||||
|
|
||||||
|
from pytest_unordered import unordered
|
||||||
|
|
||||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||||
from homeassistant.components.freebox.const import DOMAIN
|
from homeassistant.components.freebox.const import DOMAIN
|
||||||
@ -22,7 +24,7 @@ async def test_reboot_button(hass: HomeAssistant, router: Mock) -> None:
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
assert await async_setup_component(hass, DOMAIN, {})
|
assert await async_setup_component(hass, DOMAIN, {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.config_entries.async_entries() == [entry]
|
assert hass.config_entries.async_entries() == unordered([entry, ANY])
|
||||||
|
|
||||||
assert router.call_count == 1
|
assert router.call_count == 1
|
||||||
assert router().open.call_count == 1
|
assert router().open.call_count == 1
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""Tests for the Freebox config flow."""
|
"""Tests for the Freebox config flow."""
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import ANY, Mock, patch
|
||||||
|
|
||||||
|
from pytest_unordered import unordered
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import DOMAIN as DT_DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN as DT_DOMAIN
|
||||||
from homeassistant.components.freebox.const import DOMAIN, SERVICE_REBOOT
|
from homeassistant.components.freebox.const import DOMAIN, SERVICE_REBOOT
|
||||||
@ -25,7 +27,7 @@ async def test_setup(hass: HomeAssistant, router: Mock) -> None:
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
assert await async_setup_component(hass, DOMAIN, {})
|
assert await async_setup_component(hass, DOMAIN, {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.config_entries.async_entries() == [entry]
|
assert hass.config_entries.async_entries() == unordered([entry, ANY])
|
||||||
|
|
||||||
assert router.call_count == 1
|
assert router.call_count == 1
|
||||||
assert router().open.call_count == 1
|
assert router().open.call_count == 1
|
||||||
@ -57,7 +59,7 @@ async def test_setup_import(hass: HomeAssistant, router: Mock) -> None:
|
|||||||
hass, DOMAIN, {DOMAIN: {CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT}}
|
hass, DOMAIN, {DOMAIN: {CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT}}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.config_entries.async_entries() == [entry]
|
assert hass.config_entries.async_entries() == unordered([entry, ANY])
|
||||||
|
|
||||||
assert router.call_count == 1
|
assert router.call_count == 1
|
||||||
assert router().open.call_count == 1
|
assert router().open.call_count == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user