mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add configurator to strict typing (#87279)
This commit is contained in:
@@ -4,12 +4,13 @@ from datetime import timedelta
|
||||
|
||||
import homeassistant.components.configurator as configurator
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
|
||||
async def test_request_least_info(hass):
|
||||
async def test_request_least_info(hass: HomeAssistant) -> None:
|
||||
"""Test request config with least amount of data."""
|
||||
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
|
||||
|
||||
@@ -27,7 +28,7 @@ async def test_request_least_info(hass):
|
||||
assert state.attributes.get(configurator.ATTR_CONFIGURE_ID) == request_id
|
||||
|
||||
|
||||
async def test_request_all_info(hass):
|
||||
async def test_request_all_info(hass: HomeAssistant) -> None:
|
||||
"""Test request config with all possible info."""
|
||||
exp_attr = {
|
||||
ATTR_FRIENDLY_NAME: "Test Request",
|
||||
@@ -61,7 +62,7 @@ async def test_request_all_info(hass):
|
||||
assert state.attributes == exp_attr
|
||||
|
||||
|
||||
async def test_callback_called_on_configure(hass):
|
||||
async def test_callback_called_on_configure(hass: HomeAssistant) -> None:
|
||||
"""Test if our callback gets called when configure service called."""
|
||||
calls = []
|
||||
request_id = configurator.async_request_config(
|
||||
@@ -78,7 +79,7 @@ async def test_callback_called_on_configure(hass):
|
||||
assert len(calls) == 1, "Callback not called"
|
||||
|
||||
|
||||
async def test_state_change_on_notify_errors(hass):
|
||||
async def test_state_change_on_notify_errors(hass: HomeAssistant) -> None:
|
||||
"""Test state change on notify errors."""
|
||||
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
|
||||
error = "Oh no bad bad bad"
|
||||
@@ -90,12 +91,14 @@ async def test_state_change_on_notify_errors(hass):
|
||||
assert state.attributes.get(configurator.ATTR_ERRORS) == error
|
||||
|
||||
|
||||
async def test_notify_errors_fail_silently_on_bad_request_id(hass):
|
||||
async def test_notify_errors_fail_silently_on_bad_request_id(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test if notify errors fails silently with a bad request id."""
|
||||
configurator.async_notify_errors(hass, 2015, "Try this error")
|
||||
|
||||
|
||||
async def test_request_done_works(hass):
|
||||
async def test_request_done_works(hass: HomeAssistant) -> None:
|
||||
"""Test if calling request done works."""
|
||||
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
|
||||
configurator.async_request_done(hass, request_id)
|
||||
@@ -105,6 +108,8 @@ async def test_request_done_works(hass):
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
async def test_request_done_fail_silently_on_bad_request_id(hass):
|
||||
async def test_request_done_fail_silently_on_bad_request_id(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test that request_done fails silently with a bad request id."""
|
||||
configurator.async_request_done(hass, 2016)
|
||||
|
||||
Reference in New Issue
Block a user