Prevent 3rd party lib from opening sockets in wallbox tests (#56308)

This commit is contained in:
Erik Montnemery 2021-09-17 12:50:11 +02:00 committed by GitHub
parent a793fd4134
commit e0a232aa36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,10 @@
"""Test the Wallbox config flow."""
import json
from unittest.mock import patch
import requests_mock
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.core import HomeAssistant
@ -24,29 +23,6 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
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):
"""Test we handle cannot connect error."""
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}',
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(
result["flow_id"],
{