mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Prevent 3rd party lib from opening sockets in glances tests (#56345)
This commit is contained in:
parent
be0819b456
commit
39bc127dd6
@ -1,13 +1,13 @@
|
||||
"""Tests for Glances config flow."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from glances_api import Glances
|
||||
from glances_api import exceptions
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components import glances
|
||||
from homeassistant.const import CONF_SCAN_INTERVAL
|
||||
|
||||
from tests.common import MockConfigEntry, mock_coro
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
NAME = "Glances"
|
||||
HOST = "0.0.0.0"
|
||||
@ -38,9 +38,7 @@ async def test_form(hass):
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch("glances_api.Glances"), patch.object(
|
||||
Glances, "get_data", return_value=mock_coro()
|
||||
):
|
||||
with patch("homeassistant.components.glances.Glances.get_data", autospec=True):
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||
@ -54,7 +52,10 @@ async def test_form(hass):
|
||||
async def test_form_cannot_connect(hass):
|
||||
"""Test to return error if we cannot connect."""
|
||||
|
||||
with patch("glances_api.Glances"):
|
||||
with patch(
|
||||
"homeassistant.components.glances.Glances.get_data",
|
||||
side_effect=exceptions.GlancesApiConnectionError,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
glances.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user