diff --git a/tests/components/acmeda/conftest.py b/tests/components/acmeda/conftest.py index 2c980351c09..4a803711959 100644 --- a/tests/components/acmeda/conftest.py +++ b/tests/components/acmeda/conftest.py @@ -1,5 +1,8 @@ """Define fixtures available for all Acmeda tests.""" +from collections.abc import Generator +from unittest.mock import AsyncMock, patch + import pytest from homeassistant.components.acmeda.const import DOMAIN @@ -18,3 +21,10 @@ def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry: ) mock_config_entry.add_to_hass(hass) return mock_config_entry + + +@pytest.fixture +def mock_hub_run() -> Generator[AsyncMock]: + """Mock the hub run method.""" + with patch("homeassistant.components.acmeda.hub.aiopulse.Hub.run") as mock_run: + yield mock_run diff --git a/tests/components/acmeda/test_config_flow.py b/tests/components/acmeda/test_config_flow.py index 5227d283f25..9fb0d7e645b 100644 --- a/tests/components/acmeda/test_config_flow.py +++ b/tests/components/acmeda/test_config_flow.py @@ -28,13 +28,6 @@ def mock_hub_discover(): yield mock_discover -@pytest.fixture -def mock_hub_run(): - """Mock the hub run method.""" - with patch("aiopulse.Hub.run") as mock_run: - yield mock_run - - async def async_generator(items): """Async yields items provided in a list.""" for item in items: @@ -56,9 +49,8 @@ async def test_show_form_no_hubs(hass: HomeAssistant, mock_hub_discover) -> None assert len(mock_hub_discover.mock_calls) == 1 -async def test_show_form_one_hub( - hass: HomeAssistant, mock_hub_discover, mock_hub_run -) -> None: +@pytest.mark.usesfixtures("mock_hub_run") +async def test_show_form_one_hub(hass: HomeAssistant, mock_hub_discover) -> None: """Test that a config is created when one hub discovered.""" dummy_hub_1 = aiopulse.Hub(DUMMY_HOST1) @@ -102,9 +94,8 @@ async def test_show_form_two_hubs(hass: HomeAssistant, mock_hub_discover) -> Non assert len(mock_hub_discover.mock_calls) == 1 -async def test_create_second_entry( - hass: HomeAssistant, mock_hub_run, mock_hub_discover -) -> None: +@pytest.mark.usesfixtures("mock_hub_run") +async def test_create_second_entry(hass: HomeAssistant, mock_hub_discover) -> None: """Test that a config is created when a second hub is discovered.""" dummy_hub_1 = aiopulse.Hub(DUMMY_HOST1) diff --git a/tests/components/acmeda/test_cover.py b/tests/components/acmeda/test_cover.py index 0d908ecc915..f4acc270065 100644 --- a/tests/components/acmeda/test_cover.py +++ b/tests/components/acmeda/test_cover.py @@ -1,5 +1,7 @@ """Define tests for the Acmeda config flow.""" +import pytest + from homeassistant.components.acmeda.const import DOMAIN from homeassistant.components.cover import DOMAIN as COVER_DOMAIN from homeassistant.core import HomeAssistant @@ -8,6 +10,7 @@ from homeassistant.helpers import entity_registry as er from tests.common import MockConfigEntry +@pytest.mark.usesfixtures("mock_hub_run") async def test_cover_id_migration( hass: HomeAssistant, mock_config_entry: MockConfigEntry, diff --git a/tests/components/acmeda/test_sensor.py b/tests/components/acmeda/test_sensor.py index 3d7090ce7dd..a7e60ec7187 100644 --- a/tests/components/acmeda/test_sensor.py +++ b/tests/components/acmeda/test_sensor.py @@ -1,5 +1,7 @@ """Define tests for the Acmeda config flow.""" +import pytest + from homeassistant.components.acmeda.const import DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.core import HomeAssistant @@ -8,6 +10,7 @@ from homeassistant.helpers import entity_registry as er from tests.common import MockConfigEntry +@pytest.mark.usesfixtures("mock_hub_run") async def test_sensor_id_migration( hass: HomeAssistant, mock_config_entry: MockConfigEntry,