Skip to content

Commit

Permalink
Bump wallbox to 0.4.9 (#72978)
Browse files Browse the repository at this point in the history
  • Loading branch information
hesselonline authored and balloob committed Jun 6, 2022
1 parent 39c6a57 commit b50e3d5
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 128 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/wallbox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Wallbox",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/wallbox",
"requirements": ["wallbox==0.4.4"],
"requirements": ["wallbox==0.4.9"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ vultr==0.1.2
wakeonlan==2.0.1

# homeassistant.components.wallbox
wallbox==0.4.4
wallbox==0.4.9

# homeassistant.components.waqi
waqiasync==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ vultr==0.1.2
wakeonlan==2.0.1

# homeassistant.components.wallbox
wallbox==0.4.4
wallbox==0.4.9

# homeassistant.components.folder_watcher
watchdog==2.1.8
Expand Down
39 changes: 30 additions & 9 deletions tests/components/wallbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant

from .const import ERROR, JWT, STATUS, TTL, USER_ID
from .const import ERROR, STATUS, TTL, USER_ID

from tests.common import MockConfigEntry

Expand Down Expand Up @@ -54,11 +54,32 @@
authorisation_response = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
"data": {
"attributes": {
"token": "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
}
}
}
)
)


authorisation_response_unauthorised = json.loads(
json.dumps(
{
"data": {
"attributes": {
"token": "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 404,
}
}
}
)
)
Expand All @@ -81,7 +102,7 @@ async def setup_integration(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=HTTPStatus.OK,
)
Expand All @@ -107,7 +128,7 @@ async def setup_integration_connection_error(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=HTTPStatus.FORBIDDEN,
)
Expand All @@ -133,7 +154,7 @@ async def setup_integration_read_only(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=HTTPStatus.OK,
)
Expand Down
44 changes: 12 additions & 32 deletions tests/components/wallbox/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
)
from homeassistant.core import HomeAssistant

from tests.components.wallbox import entry, setup_integration
from tests.components.wallbox.const import ERROR, JWT, STATUS, TTL, USER_ID
from tests.components.wallbox import (
authorisation_response,
authorisation_response_unauthorised,
entry,
setup_integration,
)

test_response = json.loads(
json.dumps(
Expand All @@ -34,30 +38,6 @@
)
)

authorisation_response = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
}
)
)

authorisation_response_unauthorised = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 404,
}
)
)


async def test_show_set_form(hass: HomeAssistant) -> None:
"""Test that the setup form is served."""
Expand All @@ -77,7 +57,7 @@ async def test_form_cannot_authenticate(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=HTTPStatus.FORBIDDEN,
)
Expand Down Expand Up @@ -107,7 +87,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response_unauthorised,
status_code=HTTPStatus.NOT_FOUND,
)
Expand Down Expand Up @@ -137,7 +117,7 @@ async def test_form_validate_input(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=HTTPStatus.OK,
)
Expand Down Expand Up @@ -166,8 +146,8 @@ async def test_form_reauth(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
text='{"jwt":"fakekeyhere","user_id":12345,"ttl":145656758,"error":false,"status":200}',
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
mock_request.get(
Expand Down Expand Up @@ -206,7 +186,7 @@ async def test_form_reauth_invalid(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
text='{"jwt":"fakekeyhere","user_id":12345,"ttl":145656758,"error":false,"status":200}',
status_code=200,
)
Expand Down
18 changes: 3 additions & 15 deletions tests/components/wallbox/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,12 @@

from tests.components.wallbox import (
DOMAIN,
authorisation_response,
entry,
setup_integration,
setup_integration_connection_error,
setup_integration_read_only,
)
from tests.components.wallbox.const import ERROR, JWT, STATUS, TTL, USER_ID

authorisation_response = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
}
)
)


async def test_wallbox_setup_unload_entry(hass: HomeAssistant) -> None:
Expand Down Expand Up @@ -59,7 +47,7 @@ async def test_wallbox_refresh_failed_invalid_auth(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=403,
)
Expand All @@ -85,7 +73,7 @@ async def test_wallbox_refresh_failed_connection_error(hass: HomeAssistant) -> N

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down
26 changes: 4 additions & 22 deletions tests/components/wallbox/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,12 @@
from homeassistant.core import HomeAssistant

from tests.components.wallbox import (
authorisation_response,
entry,
setup_integration,
setup_integration_read_only,
)
from tests.components.wallbox.const import (
ERROR,
JWT,
MOCK_LOCK_ENTITY_ID,
STATUS,
TTL,
USER_ID,
)

authorisation_response = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
}
)
)
from tests.components.wallbox.const import MOCK_LOCK_ENTITY_ID


async def test_wallbox_lock_class(hass: HomeAssistant) -> None:
Expand All @@ -47,7 +29,7 @@ async def test_wallbox_lock_class(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down Expand Up @@ -85,7 +67,7 @@ async def test_wallbox_lock_class_connection_error(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down
27 changes: 4 additions & 23 deletions tests/components/wallbox/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,8 @@
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 (
ERROR,
JWT,
MOCK_NUMBER_ENTITY_ID,
STATUS,
TTL,
USER_ID,
)

authorisation_response = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
}
)
)
from tests.components.wallbox import authorisation_response, entry, setup_integration
from tests.components.wallbox.const import MOCK_NUMBER_ENTITY_ID


async def test_wallbox_number_class(hass: HomeAssistant) -> None:
Expand All @@ -39,7 +20,7 @@ async def test_wallbox_number_class(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down Expand Up @@ -68,7 +49,7 @@ async def test_wallbox_number_class_connection_error(hass: HomeAssistant) -> Non

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down
29 changes: 5 additions & 24 deletions tests/components/wallbox/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,8 @@
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 (
ERROR,
JWT,
MOCK_SWITCH_ENTITY_ID,
STATUS,
TTL,
USER_ID,
)

authorisation_response = json.loads(
json.dumps(
{
JWT: "fakekeyhere",
USER_ID: 12345,
TTL: 145656758,
ERROR: "false",
STATUS: 200,
}
)
)
from tests.components.wallbox import authorisation_response, entry, setup_integration
from tests.components.wallbox.const import MOCK_SWITCH_ENTITY_ID


async def test_wallbox_switch_class(hass: HomeAssistant) -> None:
Expand All @@ -44,7 +25,7 @@ async def test_wallbox_switch_class(hass: HomeAssistant) -> None:

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down Expand Up @@ -82,7 +63,7 @@ async def test_wallbox_switch_class_connection_error(hass: HomeAssistant) -> Non

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down Expand Up @@ -121,7 +102,7 @@ async def test_wallbox_switch_class_authentication_error(hass: HomeAssistant) ->

with requests_mock.Mocker() as mock_request:
mock_request.get(
"https://api.wall-box.com/auth/token/user",
"https://user-api.wall-box.com/users/signin",
json=authorisation_response,
status_code=200,
)
Expand Down

0 comments on commit b50e3d5

Please sign in to comment.