diff --git a/tests/components/glances/test_config_flow.py b/tests/components/glances/test_config_flow.py index c9a2c333b8b..1b2c2434fab 100644 --- a/tests/components/glances/test_config_flow.py +++ b/tests/components/glances/test_config_flow.py @@ -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} )