From 4b22f04505e4a18d96b1d4ec05fd8123c9f32f53 Mon Sep 17 00:00:00 2001 From: hesselonline Date: Fri, 25 Mar 2022 18:09:49 +0100 Subject: [PATCH] Add typing to test files for Wallbox (#68635) Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- tests/components/wallbox/__init__.py | 7 ++++--- tests/components/wallbox/test_config_flow.py | 10 +++++----- tests/components/wallbox/test_init.py | 10 +++++----- tests/components/wallbox/test_lock.py | 6 +++--- tests/components/wallbox/test_number.py | 5 +++-- tests/components/wallbox/test_sensor.py | 3 ++- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/components/wallbox/__init__.py b/tests/components/wallbox/__init__.py index fe9aa1ef3d6..8a31d2ebcd5 100644 --- a/tests/components/wallbox/__init__.py +++ b/tests/components/wallbox/__init__.py @@ -23,6 +23,7 @@ from homeassistant.components.wallbox.const import ( DOMAIN, ) from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant from .const import CONF_ERROR, CONF_JWT, CONF_STATUS, CONF_TTL, CONF_USER_ID @@ -71,7 +72,7 @@ entry = MockConfigEntry( ) -async def setup_integration(hass): +async def setup_integration(hass: HomeAssistant) -> None: """Test wallbox sensor class setup.""" entry.add_to_hass(hass) @@ -99,7 +100,7 @@ async def setup_integration(hass): await hass.async_block_till_done() -async def setup_integration_connection_error(hass): +async def setup_integration_connection_error(hass: HomeAssistant) -> None: """Test wallbox sensor class setup with a connection error.""" with requests_mock.Mocker() as mock_request: @@ -125,7 +126,7 @@ async def setup_integration_connection_error(hass): await hass.async_block_till_done() -async def setup_integration_read_only(hass): +async def setup_integration_read_only(hass: HomeAssistant) -> None: """Test wallbox sensor class setup for read only.""" with requests_mock.Mocker() as mock_request: diff --git a/tests/components/wallbox/test_config_flow.py b/tests/components/wallbox/test_config_flow.py index 01993d88968..93f3fe77e10 100644 --- a/tests/components/wallbox/test_config_flow.py +++ b/tests/components/wallbox/test_config_flow.py @@ -75,7 +75,7 @@ async def test_show_set_form(hass: HomeAssistant) -> None: assert result["step_id"] == "user" -async def test_form_cannot_authenticate(hass): +async def test_form_cannot_authenticate(hass: HomeAssistant) -> None: """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -105,7 +105,7 @@ async def test_form_cannot_authenticate(hass): assert result2["errors"] == {"base": "invalid_auth"} -async def test_form_cannot_connect(hass): +async def test_form_cannot_connect(hass: HomeAssistant) -> None: """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -135,7 +135,7 @@ async def test_form_cannot_connect(hass): assert result2["errors"] == {"base": "cannot_connect"} -async def test_form_validate_input(hass): +async def test_form_validate_input(hass: HomeAssistant) -> None: """Test we can validate input.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -165,7 +165,7 @@ async def test_form_validate_input(hass): assert result2["data"]["station"] == "12345" -async def test_form_reauth(hass): +async def test_form_reauth(hass: HomeAssistant) -> None: """Test we handle reauth flow.""" await setup_integration(hass) assert entry.state == config_entries.ConfigEntryState.LOADED @@ -205,7 +205,7 @@ async def test_form_reauth(hass): await hass.config_entries.async_unload(entry.entry_id) -async def test_form_reauth_invalid(hass): +async def test_form_reauth_invalid(hass: HomeAssistant) -> None: """Test we handle reauth invalid flow.""" await setup_integration(hass) assert entry.state == config_entries.ConfigEntryState.LOADED diff --git a/tests/components/wallbox/test_init.py b/tests/components/wallbox/test_init.py index 66f0701e42e..79e6871faca 100644 --- a/tests/components/wallbox/test_init.py +++ b/tests/components/wallbox/test_init.py @@ -37,7 +37,7 @@ authorisation_response = json.loads( ) -async def test_wallbox_setup_unload_entry(hass: HomeAssistant): +async def test_wallbox_setup_unload_entry(hass: HomeAssistant) -> None: """Test Wallbox Unload.""" await setup_integration(hass) @@ -47,7 +47,7 @@ async def test_wallbox_setup_unload_entry(hass: HomeAssistant): assert entry.state == ConfigEntryState.NOT_LOADED -async def test_wallbox_unload_entry_connection_error(hass: HomeAssistant): +async def test_wallbox_unload_entry_connection_error(hass: HomeAssistant) -> None: """Test Wallbox Unload Connection Error.""" await setup_integration_connection_error(hass) @@ -57,7 +57,7 @@ async def test_wallbox_unload_entry_connection_error(hass: HomeAssistant): assert entry.state == ConfigEntryState.NOT_LOADED -async def test_wallbox_refresh_failed_invalid_auth(hass: HomeAssistant): +async def test_wallbox_refresh_failed_invalid_auth(hass: HomeAssistant) -> None: """Test Wallbox setup with authentication error.""" await setup_integration(hass) @@ -83,7 +83,7 @@ async def test_wallbox_refresh_failed_invalid_auth(hass: HomeAssistant): assert entry.state == ConfigEntryState.NOT_LOADED -async def test_wallbox_refresh_failed_connection_error(hass: HomeAssistant): +async def test_wallbox_refresh_failed_connection_error(hass: HomeAssistant) -> None: """Test Wallbox setup with connection error.""" await setup_integration(hass) @@ -109,7 +109,7 @@ async def test_wallbox_refresh_failed_connection_error(hass: HomeAssistant): assert entry.state == ConfigEntryState.NOT_LOADED -async def test_wallbox_refresh_failed_read_only(hass: HomeAssistant): +async def test_wallbox_refresh_failed_read_only(hass: HomeAssistant) -> None: """Test Wallbox setup for read-only user.""" await setup_integration_read_only(hass) diff --git a/tests/components/wallbox/test_lock.py b/tests/components/wallbox/test_lock.py index 7e24f997825..4ea9132c675 100644 --- a/tests/components/wallbox/test_lock.py +++ b/tests/components/wallbox/test_lock.py @@ -36,7 +36,7 @@ authorisation_response = json.loads( ) -async def test_wallbox_lock_class(hass: HomeAssistant): +async def test_wallbox_lock_class(hass: HomeAssistant) -> None: """Test wallbox lock class.""" await setup_integration(hass) @@ -78,7 +78,7 @@ async def test_wallbox_lock_class(hass: HomeAssistant): await hass.config_entries.async_unload(entry.entry_id) -async def test_wallbox_lock_class_connection_error(hass: HomeAssistant): +async def test_wallbox_lock_class_connection_error(hass: HomeAssistant) -> None: """Test wallbox lock class connection error.""" await setup_integration(hass) @@ -117,7 +117,7 @@ async def test_wallbox_lock_class_connection_error(hass: HomeAssistant): await hass.config_entries.async_unload(entry.entry_id) -async def test_wallbox_lock_class_authentication_error(hass: HomeAssistant): +async def test_wallbox_lock_class_authentication_error(hass: HomeAssistant) -> None: """Test wallbox lock not loaded on authentication error.""" await setup_integration_read_only(hass) diff --git a/tests/components/wallbox/test_number.py b/tests/components/wallbox/test_number.py index 989cb1b3c31..e247aa59ece 100644 --- a/tests/components/wallbox/test_number.py +++ b/tests/components/wallbox/test_number.py @@ -7,6 +7,7 @@ import requests_mock from homeassistant.components.input_number import ATTR_VALUE, SERVICE_SET_VALUE from homeassistant.components.wallbox import CONF_MAX_CHARGING_CURRENT_KEY from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.core import HomeAssistant from tests.components.wallbox import entry, setup_integration from tests.components.wallbox.const import ( @@ -31,7 +32,7 @@ authorisation_response = json.loads( ) -async def test_wallbox_number_class(hass): +async def test_wallbox_number_class(hass: HomeAssistant) -> None: """Test wallbox sensor class.""" await setup_integration(hass) @@ -60,7 +61,7 @@ async def test_wallbox_number_class(hass): await hass.config_entries.async_unload(entry.entry_id) -async def test_wallbox_number_class_connection_error(hass): +async def test_wallbox_number_class_connection_error(hass: HomeAssistant) -> None: """Test wallbox sensor class.""" await setup_integration(hass) diff --git a/tests/components/wallbox/test_sensor.py b/tests/components/wallbox/test_sensor.py index 2551eed6a2e..360040e1c2b 100644 --- a/tests/components/wallbox/test_sensor.py +++ b/tests/components/wallbox/test_sensor.py @@ -1,5 +1,6 @@ """Test Wallbox Switch component.""" from homeassistant.const import CONF_ICON, CONF_UNIT_OF_MEASUREMENT, POWER_KILO_WATT +from homeassistant.core import HomeAssistant from tests.components.wallbox import entry, setup_integration from tests.components.wallbox.const import ( @@ -9,7 +10,7 @@ from tests.components.wallbox.const import ( ) -async def test_wallbox_sensor_class(hass): +async def test_wallbox_sensor_class(hass: HomeAssistant) -> None: """Test wallbox sensor class.""" await setup_integration(hass)