From 9cdb7bba4c1fdbd4f1ff26c01912ba9a8afb3b8f Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 30 Aug 2022 18:57:42 +0200 Subject: [PATCH] Fix glances config-flow flaky test (#77549) --- .coveragerc | 1 - homeassistant/components/glances/const.py | 5 +---- tests/components/glances/test_config_flow.py | 13 ++++++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.coveragerc b/.coveragerc index 9301edcec52..770cfb978d9 100644 --- a/.coveragerc +++ b/.coveragerc @@ -441,7 +441,6 @@ omit = homeassistant/components/gitlab_ci/sensor.py homeassistant/components/gitter/sensor.py homeassistant/components/glances/__init__.py - homeassistant/components/glances/const.py homeassistant/components/glances/sensor.py homeassistant/components/goalfeed/* homeassistant/components/goodwe/__init__.py diff --git a/homeassistant/components/glances/const.py b/homeassistant/components/glances/const.py index 92fe8ba91f6..efcc30c057b 100644 --- a/homeassistant/components/glances/const.py +++ b/homeassistant/components/glances/const.py @@ -13,7 +13,4 @@ DEFAULT_SCAN_INTERVAL = 60 DATA_UPDATED = "glances_data_updated" SUPPORTED_VERSIONS = [2, 3] -if sys.maxsize > 2**32: - CPU_ICON = "mdi:cpu-64-bit" -else: - CPU_ICON = "mdi:cpu-32-bit" +CPU_ICON = f"mdi:cpu-{64 if sys.maxsize > 2**32 else 32}-bit" diff --git a/tests/components/glances/test_config_flow.py b/tests/components/glances/test_config_flow.py index 8ee669ae84e..7b2dee6429e 100644 --- a/tests/components/glances/test_config_flow.py +++ b/tests/components/glances/test_config_flow.py @@ -7,6 +7,7 @@ import pytest from homeassistant import config_entries, data_entry_flow from homeassistant.components import glances from homeassistant.const import CONF_SCAN_INTERVAL +from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry @@ -36,7 +37,7 @@ def glances_setup_fixture(): yield -async def test_form(hass): +async def test_form(hass: HomeAssistant) -> None: """Test config entry configured successfully.""" result = await hass.config_entries.flow.async_init( @@ -56,7 +57,7 @@ async def test_form(hass): assert result["data"] == DEMO_USER_INPUT -async def test_form_cannot_connect(hass): +async def test_form_cannot_connect(hass: HomeAssistant) -> None: """Test to return error if we cannot connect.""" with patch( @@ -74,7 +75,7 @@ async def test_form_cannot_connect(hass): assert result["errors"] == {"base": "cannot_connect"} -async def test_form_wrong_version(hass): +async def test_form_wrong_version(hass: HomeAssistant) -> None: """Test to check if wrong version is entered.""" user_input = DEMO_USER_INPUT.copy() @@ -90,7 +91,7 @@ async def test_form_wrong_version(hass): assert result["errors"] == {"version": "wrong_version"} -async def test_form_already_configured(hass): +async def test_form_already_configured(hass: HomeAssistant) -> None: """Test host is already configured.""" entry = MockConfigEntry( domain=glances.DOMAIN, data=DEMO_USER_INPUT, options={CONF_SCAN_INTERVAL: 60} @@ -107,12 +108,14 @@ async def test_form_already_configured(hass): assert result["reason"] == "already_configured" -async def test_options(hass): +async def test_options(hass: HomeAssistant) -> None: """Test options for Glances.""" entry = MockConfigEntry( domain=glances.DOMAIN, data=DEMO_USER_INPUT, options={CONF_SCAN_INTERVAL: 60} ) entry.add_to_hass(hass) + await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() result = await hass.config_entries.options.async_init(entry.entry_id) -- GitLab