Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/components/cert_expiry/conftest.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 4 additions & 6 deletions tests/components/cert_expiry/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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
Expand All @@ -13,6 +15,8 @@

from tests.common import MockConfigEntry

pytestmark = pytest.mark.usefixtures("mock_setup_entry")


async def test_user(hass: HomeAssistant) -> None:
"""Test user config."""
Expand All @@ -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."""
Expand All @@ -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."""
Expand Down