Add typing to test files for Wallbox (#68635)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>pull/68680/head
parent
3ef912b7a0
commit
4b22f04505
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue