mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Prevent 3rd party lib from opening sockets in wallbox tests (#56308)
This commit is contained in:
parent
a793fd4134
commit
e0a232aa36
@ -1,11 +1,10 @@
|
|||||||
"""Test the Wallbox config flow."""
|
"""Test the Wallbox config flow."""
|
||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import requests_mock
|
import requests_mock
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.wallbox import InvalidAuth, config_flow
|
from homeassistant.components.wallbox import config_flow
|
||||||
from homeassistant.components.wallbox.const import DOMAIN
|
from homeassistant.components.wallbox.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
@ -24,29 +23,6 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
|
|||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
|
||||||
async def test_form_invalid_auth(hass):
|
|
||||||
"""Test we handle invalid auth."""
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"homeassistant.components.wallbox.config_flow.WallboxHub.async_authenticate",
|
|
||||||
side_effect=InvalidAuth,
|
|
||||||
):
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
|
||||||
result["flow_id"],
|
|
||||||
{
|
|
||||||
"station": "12345",
|
|
||||||
"username": "test-username",
|
|
||||||
"password": "test-password",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result2["type"] == "form"
|
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
|
||||||
|
|
||||||
|
|
||||||
async def test_form_cannot_authenticate(hass):
|
async def test_form_cannot_authenticate(hass):
|
||||||
"""Test we handle cannot connect error."""
|
"""Test we handle cannot connect error."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -59,19 +35,6 @@ async def test_form_cannot_authenticate(hass):
|
|||||||
text='{"jwt":"fakekeyhere","user_id":12345,"ttl":145656758,"error":false,"status":200}',
|
text='{"jwt":"fakekeyhere","user_id":12345,"ttl":145656758,"error":false,"status":200}',
|
||||||
status_code=403,
|
status_code=403,
|
||||||
)
|
)
|
||||||
mock_request.get(
|
|
||||||
"https://api.wall-box.com/chargers/status/12345",
|
|
||||||
text='{"Temperature": 100, "Location": "Toronto", "Datetime": "2020-07-23", "Units": "Celsius"}',
|
|
||||||
status_code=403,
|
|
||||||
)
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
|
||||||
result["flow_id"],
|
|
||||||
{
|
|
||||||
"station": "12345",
|
|
||||||
"username": "test-username",
|
|
||||||
"password": "test-password",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user