Add missing mock in cert_expiry config flow tests (#88835)

This commit is contained in:
epenet 2023-02-27 14:01:53 +01:00 committed by GitHub
parent 76819fbb23
commit 5cc9e7fedd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View 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

View file

@ -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."""