Add type hints to integration tests (part 17) (#88163)

This commit is contained in:
epenet 2023-02-15 11:14:04 +01:00 committed by GitHub
parent 04e9c7748f
commit 2cdc741900
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 469 additions and 251 deletions

View file

@ -63,7 +63,7 @@ class PilightDaemonSim:
@patch("homeassistant.components.pilight._LOGGER.error")
async def test_connection_failed_error(mock_error, hass):
async def test_connection_failed_error(mock_error, hass: HomeAssistant) -> None:
"""Try to connect at 127.0.0.1:5001 with socket error."""
with assert_setup_component(4), patch(
"pilight.pilight.Client", side_effect=socket.error
@ -78,7 +78,7 @@ async def test_connection_failed_error(mock_error, hass):
@patch("homeassistant.components.pilight._LOGGER.error")
async def test_connection_timeout_error(mock_error, hass):
async def test_connection_timeout_error(mock_error, hass: HomeAssistant) -> None:
"""Try to connect at 127.0.0.1:5001 with socket timeout."""
with assert_setup_component(4), patch(
"pilight.pilight.Client", side_effect=socket.timeout
@ -114,7 +114,7 @@ async def test_send_code_no_protocol(hass: HomeAssistant) -> None:
@patch("homeassistant.components.pilight._LOGGER.error")
@patch("homeassistant.components.pilight._LOGGER", _LOGGER)
@patch("pilight.pilight.Client", PilightDaemonSim)
async def test_send_code(mock_pilight_error, hass):
async def test_send_code(mock_pilight_error, hass: HomeAssistant) -> None:
"""Try to send proper data."""
with assert_setup_component(4):
assert await async_setup_component(hass, pilight.DOMAIN, {pilight.DOMAIN: {}})
@ -135,7 +135,7 @@ async def test_send_code(mock_pilight_error, hass):
@patch("pilight.pilight.Client", PilightDaemonSim)
@patch("homeassistant.components.pilight._LOGGER.error")
async def test_send_code_fail(mock_pilight_error, hass):
async def test_send_code_fail(mock_pilight_error, hass: HomeAssistant) -> None:
"""Check IOError exception error message."""
with assert_setup_component(4), patch(
"pilight.pilight.Client.send_code", side_effect=IOError
@ -158,7 +158,7 @@ async def test_send_code_fail(mock_pilight_error, hass):
@patch("homeassistant.components.pilight._LOGGER.error")
@patch("homeassistant.components.pilight._LOGGER", _LOGGER)
@patch("pilight.pilight.Client", PilightDaemonSim)
async def test_send_code_delay(mock_pilight_error, hass):
async def test_send_code_delay(mock_pilight_error, hass: HomeAssistant) -> None:
"""Try to send proper data with delay afterwards."""
with assert_setup_component(4):
assert await async_setup_component(
@ -200,7 +200,7 @@ async def test_send_code_delay(mock_pilight_error, hass):
@patch("homeassistant.components.pilight._LOGGER.error")
@patch("homeassistant.components.pilight._LOGGER", _LOGGER)
@patch("pilight.pilight.Client", PilightDaemonSim)
async def test_start_stop(mock_pilight_error, hass):
async def test_start_stop(mock_pilight_error, hass: HomeAssistant) -> None:
"""Check correct startup and stop of pilight daemon."""
with assert_setup_component(4):
assert await async_setup_component(hass, pilight.DOMAIN, {pilight.DOMAIN: {}})
@ -223,7 +223,7 @@ async def test_start_stop(mock_pilight_error, hass):
@patch("pilight.pilight.Client", PilightDaemonSim)
@patch("homeassistant.core._LOGGER.debug")
async def test_receive_code(mock_debug, hass):
async def test_receive_code(mock_debug, hass: HomeAssistant) -> None:
"""Check if code receiving via pilight daemon works."""
with assert_setup_component(4):
assert await async_setup_component(hass, pilight.DOMAIN, {pilight.DOMAIN: {}})
@ -249,7 +249,7 @@ async def test_receive_code(mock_debug, hass):
@patch("pilight.pilight.Client", PilightDaemonSim)
@patch("homeassistant.core._LOGGER.debug")
async def test_whitelist_exact_match(mock_debug, hass):
async def test_whitelist_exact_match(mock_debug, hass: HomeAssistant) -> None:
"""Check whitelist filter with matched data."""
with assert_setup_component(4):
whitelist = {
@ -282,7 +282,7 @@ async def test_whitelist_exact_match(mock_debug, hass):
@patch("pilight.pilight.Client", PilightDaemonSim)
@patch("homeassistant.core._LOGGER.debug")
async def test_whitelist_partial_match(mock_debug, hass):
async def test_whitelist_partial_match(mock_debug, hass: HomeAssistant) -> None:
"""Check whitelist filter with partially matched data, should work."""
with assert_setup_component(4):
whitelist = {
@ -313,7 +313,7 @@ async def test_whitelist_partial_match(mock_debug, hass):
@patch("pilight.pilight.Client", PilightDaemonSim)
@patch("homeassistant.core._LOGGER.debug")
async def test_whitelist_or_match(mock_debug, hass):
async def test_whitelist_or_match(mock_debug, hass: HomeAssistant) -> None:
"""Check whitelist filter with several subsection, should work."""
with assert_setup_component(4):
whitelist = {
@ -347,7 +347,7 @@ async def test_whitelist_or_match(mock_debug, hass):
@patch("pilight.pilight.Client", PilightDaemonSim)
@patch("homeassistant.core._LOGGER.debug")
async def test_whitelist_no_match(mock_debug, hass):
async def test_whitelist_no_match(mock_debug, hass: HomeAssistant) -> None:
"""Check whitelist filter with unmatched data, should not work."""
with assert_setup_component(4):
whitelist = {