mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Add missing mock in cert_expiry config flow tests (#88835)
This commit is contained in:
parent
76819fbb23
commit
5cc9e7fedd
14
tests/components/cert_expiry/conftest.py
Normal file
14
tests/components/cert_expiry/conftest.py
Normal file
@ -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
|
@ -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."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user