Adjust freebox tests which create devices (#98190)

This commit is contained in:
Erik Montnemery 2023-08-10 18:22:44 +02:00 committed by GitHub
parent 52183d64ae
commit 983ebeff80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@ from unittest.mock import AsyncMock, patch
import pytest
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from .const import (
@ -27,9 +28,10 @@ def mock_path():
@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."""
config_entry = MockConfigEntry(domain="something_else")
config_entry.add_to_hass(hass)
for idx, device in enumerate(
(

View File

@ -1,5 +1,7 @@
"""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.freebox.const import DOMAIN
@ -22,7 +24,7 @@ async def test_reboot_button(hass: HomeAssistant, router: Mock) -> None:
entry.add_to_hass(hass)
assert await async_setup_component(hass, DOMAIN, {})
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().open.call_count == 1

View File

@ -1,5 +1,7 @@
"""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.freebox.const import DOMAIN, SERVICE_REBOOT
@ -25,7 +27,7 @@ async def test_setup(hass: HomeAssistant, router: Mock) -> None:
entry.add_to_hass(hass)
assert await async_setup_component(hass, DOMAIN, {})
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().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}}
)
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().open.call_count == 1