diff --git a/tests/components/cert_expiry/conftest.py b/tests/components/cert_expiry/conftest.py new file mode 100644 index 00000000000..0a3f5420f60 --- /dev/null +++ b/tests/components/cert_expiry/conftest.py @@ -0,0 +1,14 @@ +"""Configuration for cert_expiry tests.""" +from collections.abc import Generator +from unittest.mock import AsyncMock, patch + +import pytest + + +@pytest.fixture +def mock_setup_entry() -> Generator[AsyncMock, None, None]: + """Override async_setup_entry.""" + with patch( + "homeassistant.components.cert_expiry.async_setup_entry", return_value=True + ) as mock_setup_entry: + yield mock_setup_entry diff --git a/tests/components/cert_expiry/test_config_flow.py b/tests/components/cert_expiry/test_config_flow.py index ae493133d12..52985da0014 100644 --- a/tests/components/cert_expiry/test_config_flow.py +++ b/tests/components/cert_expiry/test_config_flow.py @@ -3,6 +3,8 @@ import socket import ssl from unittest.mock import patch +import pytest + from homeassistant import config_entries, data_entry_flow from homeassistant.components.cert_expiry.const import DEFAULT_PORT, DOMAIN from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT @@ -13,6 +15,8 @@ from .helpers import future_timestamp from tests.common import MockConfigEntry +pytestmark = pytest.mark.usefixtures("mock_setup_entry") + async def test_user(hass: HomeAssistant) -> None: """Test user config.""" @@ -34,9 +38,6 @@ async def test_user(hass: HomeAssistant) -> None: assert result["data"][CONF_PORT] == PORT assert result["result"].unique_id == f"{HOST}:{PORT}" - with patch("homeassistant.components.cert_expiry.sensor.async_setup_entry"): - await hass.async_block_till_done() - async def test_user_with_bad_cert(hass: HomeAssistant) -> None: """Test user config with bad certificate.""" @@ -60,9 +61,6 @@ async def test_user_with_bad_cert(hass: HomeAssistant) -> None: assert result["data"][CONF_PORT] == PORT assert result["result"].unique_id == f"{HOST}:{PORT}" - with patch("homeassistant.components.cert_expiry.sensor.async_setup_entry"): - await hass.async_block_till_done() - async def test_import_host_only(hass: HomeAssistant) -> None: """Test import with host only."""