Refactor wallbox tests (#51094)

* Changed Testing, removed custom exception
Removed custom exceptions, reverted to builtin. Changed testing approach in all tests, now using the core interface to setup device and mock_requests to create test responses for all calls.

* Reintroduce InvalidAuth exception in __init__
Remove reference to internal HA exception, Reintroduce custom exception

* Removed duplicate entry in test_config_flow

* removed tests from test_init that calling methods directly

* Update tests/components/wallbox/__init__.py

Removed duplicate add_to_hass call

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
hesselonline 2021-06-27 21:06:25 +02:00 committed by GitHub
parent 2d1744c573
commit e56069558a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 137 additions and 270 deletions

View file

@ -4,7 +4,7 @@ import voluptuous as vol
from homeassistant import config_entries, core
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from . import CannotConnect, InvalidAuth, WallboxHub
from . import InvalidAuth, WallboxHub
from .const import CONF_STATION, DOMAIN
COMPONENT_DOMAIN = DOMAIN
@ -46,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=COMPONENT_DOMAIN):
try:
info = await validate_input(self.hass, user_input)
except CannotConnect:
except ConnectionError:
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"