mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 21:10:25 +00:00
Correct type hints on MQTT tests (#128299)
This commit is contained in:
@@ -236,8 +236,7 @@ async def test_waiting_for_client_not_loaded(
|
||||
|
||||
unsubs: list[Callable[[], None]] = []
|
||||
|
||||
async def _async_just_in_time_subscribe() -> Callable[[], None]:
|
||||
nonlocal unsub
|
||||
async def _async_just_in_time_subscribe() -> None:
|
||||
assert await mqtt.async_wait_for_mqtt_client(hass)
|
||||
# Awaiting a second time should work too and return True
|
||||
assert await mqtt.async_wait_for_mqtt_client(hass)
|
||||
@@ -261,12 +260,12 @@ async def test_waiting_for_client_loaded(
|
||||
"""Test waiting for client where mqtt entry is loaded."""
|
||||
unsub: Callable[[], None] | None = None
|
||||
|
||||
async def _async_just_in_time_subscribe() -> Callable[[], None]:
|
||||
async def _async_just_in_time_subscribe() -> None:
|
||||
nonlocal unsub
|
||||
assert await mqtt.async_wait_for_mqtt_client(hass)
|
||||
unsub = await mqtt.async_subscribe(hass, "test_topic", lambda msg: None)
|
||||
|
||||
entry = hass.config_entries.async_entries(mqtt.DATA_MQTT)[0]
|
||||
entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
await _async_just_in_time_subscribe()
|
||||
@@ -290,7 +289,7 @@ async def test_waiting_for_client_entry_fails(
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def _async_just_in_time_subscribe() -> Callable[[], None]:
|
||||
async def _async_just_in_time_subscribe() -> None:
|
||||
assert not await mqtt.async_wait_for_mqtt_client(hass)
|
||||
|
||||
hass.async_create_task(_async_just_in_time_subscribe())
|
||||
@@ -300,7 +299,7 @@ async def test_waiting_for_client_entry_fails(
|
||||
side_effect=Exception,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR # type:ignore[comparison-overlap]
|
||||
|
||||
|
||||
async def test_waiting_for_client_setup_fails(
|
||||
@@ -318,7 +317,7 @@ async def test_waiting_for_client_setup_fails(
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def _async_just_in_time_subscribe() -> Callable[[], None]:
|
||||
async def _async_just_in_time_subscribe() -> None:
|
||||
assert not await mqtt.async_wait_for_mqtt_client(hass)
|
||||
|
||||
hass.async_create_task(_async_just_in_time_subscribe())
|
||||
@@ -327,7 +326,7 @@ async def test_waiting_for_client_setup_fails(
|
||||
# Simulate MQTT setup fails before the client would become available
|
||||
mqtt_client_mock.connect.side_effect = Exception
|
||||
assert not await hass.config_entries.async_setup(entry.entry_id)
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR # type:ignore[comparison-overlap]
|
||||
|
||||
|
||||
@patch("homeassistant.components.mqtt.util.AVAILABILITY_TIMEOUT", 0.01)
|
||||
|
||||
Reference in New Issue
Block a user