Use async_timeout instead of asyncio.wait_for (#90496)
* Use async_timeout instead of asyncio.wait_for * fix imports * fix imports * break out Event.wait patch * Update tests/components/reolink/conftest.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Simplify --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
9cab05c4b9
commit
b47ac524ea
4 changed files with 29 additions and 14 deletions
|
@ -1,5 +1,4 @@
|
|||
"""Test the Reolink init."""
|
||||
import asyncio
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||
|
||||
|
@ -55,6 +54,7 @@ pytestmark = pytest.mark.usefixtures("reolink_connect", "reolink_platforms")
|
|||
async def test_failures_parametrized(
|
||||
hass: HomeAssistant,
|
||||
reolink_connect: MagicMock,
|
||||
reolink_ONVIF_wait: MagicMock,
|
||||
config_entry: MockConfigEntry,
|
||||
attr: str,
|
||||
value: Any,
|
||||
|
@ -71,7 +71,10 @@ async def test_failures_parametrized(
|
|||
|
||||
|
||||
async def test_entry_reloading(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, reolink_connect: MagicMock
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
reolink_ONVIF_wait: MagicMock,
|
||||
) -> None:
|
||||
"""Test the entry is reloaded correctly when settings change."""
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
@ -88,7 +91,7 @@ async def test_entry_reloading(
|
|||
|
||||
|
||||
async def test_no_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, reolink_ONVIF_wait: MagicMock
|
||||
) -> None:
|
||||
"""Test no repairs issue is raised when http local url is used."""
|
||||
await async_process_ha_core_config(
|
||||
|
@ -106,7 +109,7 @@ async def test_no_repair_issue(
|
|||
|
||||
|
||||
async def test_https_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, reolink_ONVIF_wait: MagicMock
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when https local url is used."""
|
||||
await async_process_ha_core_config(
|
||||
|
@ -125,6 +128,7 @@ async def test_port_repair_issue(
|
|||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
reolink_ONVIF_wait: MagicMock,
|
||||
protocol: str,
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when auto enable of ports fails."""
|
||||
|
@ -144,10 +148,7 @@ async def test_webhook_repair_issue(
|
|||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when the webhook url is unreachable."""
|
||||
with patch(
|
||||
"homeassistant.components.reolink.host.asyncio.Event.wait",
|
||||
AsyncMock(side_effect=asyncio.TimeoutError()),
|
||||
):
|
||||
with patch("homeassistant.components.reolink.host.FIRST_ONVIF_TIMEOUT", new=0):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -156,7 +157,10 @@ async def test_webhook_repair_issue(
|
|||
|
||||
|
||||
async def test_firmware_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, reolink_connect: MagicMock
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
reolink_ONVIF_wait: MagicMock,
|
||||
) -> None:
|
||||
"""Test firmware issue is raised when too old firmware is used."""
|
||||
reolink_connect.sw_version_update_required = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue