diff --git a/homeassistant/components/wallbox/manifest.json b/homeassistant/components/wallbox/manifest.json index 2a4978b1cc1..914adda980a 100644 --- a/homeassistant/components/wallbox/manifest.json +++ b/homeassistant/components/wallbox/manifest.json @@ -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": {}, diff --git a/requirements_all.txt b/requirements_all.txt index f365da06766..34c3904aab9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index c3178a0822f..6b8b4d0dc35 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1597,7 +1597,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 diff --git a/tests/components/wallbox/__init__.py b/tests/components/wallbox/__init__.py index 2b35bb76b2f..8c979c42ebe 100644 --- a/tests/components/wallbox/__init__.py +++ b/tests/components/wallbox/__init__.py @@ -26,7 +26,7 @@ from homeassistant.components.wallbox.const import ( 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 @@ -54,11 +54,32 @@ test_response = json.loads( 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, + } + } } ) ) @@ -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, ) @@ -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, ) @@ -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, ) diff --git a/tests/components/wallbox/test_config_flow.py b/tests/components/wallbox/test_config_flow.py index a3e6a724eef..68f70878592 100644 --- a/tests/components/wallbox/test_config_flow.py +++ b/tests/components/wallbox/test_config_flow.py @@ -18,8 +18,12 @@ from homeassistant.components.wallbox.const import ( ) 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( @@ -34,30 +38,6 @@ test_response = json.loads( ) ) -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.""" @@ -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, ) @@ -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, ) @@ -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, ) @@ -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( @@ -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, ) diff --git a/tests/components/wallbox/test_init.py b/tests/components/wallbox/test_init.py index b8862531a82..5080bab87ea 100644 --- a/tests/components/wallbox/test_init.py +++ b/tests/components/wallbox/test_init.py @@ -11,24 +11,12 @@ from . import test_response 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: @@ -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, ) @@ -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, ) diff --git a/tests/components/wallbox/test_lock.py b/tests/components/wallbox/test_lock.py index d8b2fcf182c..fbcb07b0e90 100644 --- a/tests/components/wallbox/test_lock.py +++ b/tests/components/wallbox/test_lock.py @@ -10,30 +10,12 @@ from homeassistant.const import ATTR_ENTITY_ID 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: @@ -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, ) @@ -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, ) diff --git a/tests/components/wallbox/test_number.py b/tests/components/wallbox/test_number.py index 5c024d0f4ac..c8e8b29f28b 100644 --- a/tests/components/wallbox/test_number.py +++ b/tests/components/wallbox/test_number.py @@ -9,27 +9,8 @@ from homeassistant.components.wallbox import CHARGER_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 ( - 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: @@ -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, ) @@ -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, ) diff --git a/tests/components/wallbox/test_switch.py b/tests/components/wallbox/test_switch.py index 6ade320319a..c57fee0353f 100644 --- a/tests/components/wallbox/test_switch.py +++ b/tests/components/wallbox/test_switch.py @@ -10,27 +10,8 @@ from homeassistant.components.wallbox.const import CHARGER_STATUS_ID_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 ( - 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: @@ -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, ) @@ -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, ) @@ -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, )