mirror of
https://github.com/home-assistant/core.git
synced 2025-09-11 07:41:35 +02:00
Add more exception types for cannot_connect
test in APCUPSD (#150830)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -17,12 +18,18 @@ from . import CONF_DATA, MOCK_MINIMAL_STATUS, MOCK_STATUS
|
|||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
async def test_config_flow_cannot_connect(hass: HomeAssistant) -> None:
|
@pytest.mark.parametrize(
|
||||||
"""Test config flow setup with connection error."""
|
"exception",
|
||||||
|
[OSError(), asyncio.IncompleteReadError(partial=b"", expected=100), TimeoutError()],
|
||||||
|
)
|
||||||
|
async def test_config_flow_cannot_connect(
|
||||||
|
hass: HomeAssistant, exception: Exception
|
||||||
|
) -> None:
|
||||||
|
"""Test config flow setup with a connection error."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.apcupsd.coordinator.aioapcaccess.request_status"
|
"homeassistant.components.apcupsd.coordinator.aioapcaccess.request_status"
|
||||||
) as mock_get:
|
) as mock_request_status:
|
||||||
mock_get.side_effect = OSError()
|
mock_request_status.side_effect = exception
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
Reference in New Issue
Block a user