From a7093d36872f6581de1a42320f7ac28a8cd78ad0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 11 Apr 2023 08:57:34 +0200 Subject: [PATCH 1/4] Fix flaky filesize tests (#91200) * Fix flaky filesize tests * Adjust constant usage * Once more * Use joinpath --- tests/components/filesize/__init__.py | 4 -- tests/components/filesize/conftest.py | 21 +++------ tests/components/filesize/test_config_flow.py | 44 ++++++++++--------- tests/components/filesize/test_init.py | 18 ++++---- tests/components/filesize/test_sensor.py | 22 +++++----- 5 files changed, 49 insertions(+), 60 deletions(-) diff --git a/tests/components/filesize/__init__.py b/tests/components/filesize/__init__.py index 3e09a745387..b8956d4fb80 100644 --- a/tests/components/filesize/__init__.py +++ b/tests/components/filesize/__init__.py @@ -1,13 +1,9 @@ """Tests for the filesize component.""" -import os from homeassistant.core import HomeAssistant -TEST_DIR = os.path.join(os.path.dirname(__file__)) TEST_FILE_NAME = "mock_file_test_filesize.txt" TEST_FILE_NAME2 = "mock_file_test_filesize2.txt" -TEST_FILE = os.path.join(TEST_DIR, TEST_FILE_NAME) -TEST_FILE2 = os.path.join(TEST_DIR, TEST_FILE_NAME2) async def async_create_file(hass: HomeAssistant, path: str) -> None: diff --git a/tests/components/filesize/conftest.py b/tests/components/filesize/conftest.py index 6584ebc95df..ac36ab687f4 100644 --- a/tests/components/filesize/conftest.py +++ b/tests/components/filesize/conftest.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections.abc import Generator -import os +from pathlib import Path from unittest.mock import patch import pytest @@ -10,19 +10,20 @@ import pytest from homeassistant.components.filesize.const import DOMAIN from homeassistant.const import CONF_FILE_PATH -from . import TEST_FILE, TEST_FILE2, TEST_FILE_NAME +from . import TEST_FILE_NAME from tests.common import MockConfigEntry @pytest.fixture -def mock_config_entry() -> MockConfigEntry: +def mock_config_entry(tmp_path: Path) -> MockConfigEntry: """Return the default mocked config entry.""" + test_file = str(tmp_path.joinpath(TEST_FILE_NAME)) return MockConfigEntry( title=TEST_FILE_NAME, domain=DOMAIN, - data={CONF_FILE_PATH: TEST_FILE}, - unique_id=TEST_FILE, + data={CONF_FILE_PATH: test_file}, + unique_id=test_file, ) @@ -33,13 +34,3 @@ def mock_setup_entry() -> Generator[None, None, None]: "homeassistant.components.filesize.async_setup_entry", return_value=True ): yield - - -@pytest.fixture(autouse=True) -def remove_file() -> None: - """Remove test file.""" - yield - if os.path.isfile(TEST_FILE): - os.remove(TEST_FILE) - if os.path.isfile(TEST_FILE2): - os.remove(TEST_FILE2) diff --git a/tests/components/filesize/test_config_flow.py b/tests/components/filesize/test_config_flow.py index dd99aa2a723..27dec438168 100644 --- a/tests/components/filesize/test_config_flow.py +++ b/tests/components/filesize/test_config_flow.py @@ -1,4 +1,5 @@ """Tests for the Filesize config flow.""" +from pathlib import Path from unittest.mock import patch import pytest @@ -9,54 +10,55 @@ from homeassistant.const import CONF_FILE_PATH from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType -from . import TEST_DIR, TEST_FILE, TEST_FILE_NAME, async_create_file +from . import TEST_FILE_NAME, async_create_file from tests.common import MockConfigEntry pytestmark = pytest.mark.usefixtures("mock_setup_entry") -async def test_full_user_flow(hass: HomeAssistant) -> None: +async def test_full_user_flow(hass: HomeAssistant, tmp_path: Path) -> None: """Test the full user configuration flow.""" - await async_create_file(hass, TEST_FILE) - hass.config.allowlist_external_dirs = {TEST_DIR} + test_file = str(tmp_path.joinpath(TEST_FILE_NAME)) + await async_create_file(hass, test_file) + hass.config.allowlist_external_dirs = {tmp_path} result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - user_input={CONF_FILE_PATH: TEST_FILE}, + user_input={CONF_FILE_PATH: test_file}, ) assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("title") == TEST_FILE_NAME - assert result2.get("data") == {CONF_FILE_PATH: TEST_FILE} + assert result2.get("data") == {CONF_FILE_PATH: test_file} async def test_unique_path( - hass: HomeAssistant, - mock_config_entry: MockConfigEntry, + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmp_path: Path ) -> None: """Test we abort if already setup.""" - await async_create_file(hass, TEST_FILE) - hass.config.allowlist_external_dirs = {TEST_DIR} + test_file = str(tmp_path.joinpath(TEST_FILE_NAME)) + await async_create_file(hass, test_file) + hass.config.allowlist_external_dirs = {tmp_path} mock_config_entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_FILE_PATH: TEST_FILE} + DOMAIN, context={"source": SOURCE_USER}, data={CONF_FILE_PATH: test_file} ) assert result.get("type") == FlowResultType.ABORT assert result.get("reason") == "already_configured" -async def test_flow_fails_on_validation(hass: HomeAssistant) -> None: +async def test_flow_fails_on_validation(hass: HomeAssistant, tmp_path: Path) -> None: """Test config flow errors.""" - + test_file = str(tmp_path.joinpath(TEST_FILE_NAME)) hass.config.allowlist_external_dirs = {} result = await hass.config_entries.flow.async_init( @@ -64,18 +66,18 @@ async def test_flow_fails_on_validation(hass: HomeAssistant) -> None: ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ - CONF_FILE_PATH: TEST_FILE, + CONF_FILE_PATH: test_file, }, ) assert result2["errors"] == {"base": "not_valid"} - await async_create_file(hass, TEST_FILE) + await async_create_file(hass, test_file) with patch( "homeassistant.components.filesize.config_flow.pathlib.Path", @@ -83,25 +85,25 @@ async def test_flow_fails_on_validation(hass: HomeAssistant) -> None: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ - CONF_FILE_PATH: TEST_FILE, + CONF_FILE_PATH: test_file, }, ) assert result2["errors"] == {"base": "not_allowed"} - hass.config.allowlist_external_dirs = {TEST_DIR} + hass.config.allowlist_external_dirs = {tmp_path} with patch( "homeassistant.components.filesize.config_flow.pathlib.Path", ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ - CONF_FILE_PATH: TEST_FILE, + CONF_FILE_PATH: test_file, }, ) assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["title"] == TEST_FILE_NAME assert result2["data"] == { - CONF_FILE_PATH: TEST_FILE, + CONF_FILE_PATH: test_file, } diff --git a/tests/components/filesize/test_init.py b/tests/components/filesize/test_init.py index 7c0526b8194..c580bb7da77 100644 --- a/tests/components/filesize/test_init.py +++ b/tests/components/filesize/test_init.py @@ -1,5 +1,5 @@ """Tests for the Filesize integration.""" -import py +from pathlib import Path from homeassistant.components.filesize.const import DOMAIN from homeassistant.config_entries import ConfigEntryState @@ -12,12 +12,12 @@ from tests.common import MockConfigEntry async def test_load_unload_config_entry( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: py.path.local + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmp_path: Path ) -> None: """Test the Filesize configuration entry loading/unloading.""" - testfile = f"{tmpdir}/file.txt" + testfile = str(tmp_path.joinpath("file.txt")) await async_create_file(hass, testfile) - hass.config.allowlist_external_dirs = {tmpdir} + hass.config.allowlist_external_dirs = {tmp_path} mock_config_entry.add_to_hass(hass) hass.config_entries.async_update_entry( mock_config_entry, unique_id=testfile, data={CONF_FILE_PATH: testfile} @@ -35,12 +35,12 @@ async def test_load_unload_config_entry( async def test_cannot_access_file( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: py.path.local + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmp_path: Path ) -> None: """Test that an file not exist is caught.""" mock_config_entry.add_to_hass(hass) - testfile = f"{tmpdir}/file_not_exist.txt" - hass.config.allowlist_external_dirs = {tmpdir} + testfile = str(tmp_path.joinpath("file_not_exist.txt")) + hass.config.allowlist_external_dirs = {tmp_path} hass.config_entries.async_update_entry( mock_config_entry, unique_id=testfile, data={CONF_FILE_PATH: testfile} ) @@ -52,10 +52,10 @@ async def test_cannot_access_file( async def test_not_valid_path_to_file( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: py.path.local + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmp_path: Path ) -> None: """Test that an invalid path is caught.""" - testfile = f"{tmpdir}/file.txt" + testfile = str(tmp_path.joinpath("file.txt")) await async_create_file(hass, testfile) mock_config_entry.add_to_hass(hass) hass.config_entries.async_update_entry( diff --git a/tests/components/filesize/test_sensor.py b/tests/components/filesize/test_sensor.py index bef0eceb653..20354df13bd 100644 --- a/tests/components/filesize/test_sensor.py +++ b/tests/components/filesize/test_sensor.py @@ -1,24 +1,24 @@ """The tests for the filesize sensor.""" import os - -import py +from pathlib import Path from homeassistant.const import CONF_FILE_PATH, STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_component import async_update_entity -from . import TEST_FILE, TEST_FILE_NAME, async_create_file +from . import TEST_FILE_NAME, async_create_file from tests.common import MockConfigEntry async def test_invalid_path( - hass: HomeAssistant, mock_config_entry: MockConfigEntry + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmp_path: Path ) -> None: """Test that an invalid path is caught.""" + test_file = str(tmp_path.joinpath(TEST_FILE_NAME)) mock_config_entry.add_to_hass(hass) hass.config_entries.async_update_entry( - mock_config_entry, unique_id=TEST_FILE, data={CONF_FILE_PATH: TEST_FILE} + mock_config_entry, unique_id=test_file, data={CONF_FILE_PATH: test_file} ) state = hass.states.get("sensor." + TEST_FILE_NAME) @@ -26,12 +26,12 @@ async def test_invalid_path( async def test_valid_path( - hass: HomeAssistant, tmpdir: py.path.local, mock_config_entry: MockConfigEntry + hass: HomeAssistant, tmp_path: Path, mock_config_entry: MockConfigEntry ) -> None: """Test for a valid path.""" - testfile = f"{tmpdir}/file.txt" + testfile = str(tmp_path.joinpath("file.txt")) await async_create_file(hass, testfile) - hass.config.allowlist_external_dirs = {tmpdir} + hass.config.allowlist_external_dirs = {tmp_path} mock_config_entry.add_to_hass(hass) hass.config_entries.async_update_entry( mock_config_entry, unique_id=testfile, data={CONF_FILE_PATH: testfile} @@ -48,12 +48,12 @@ async def test_valid_path( async def test_state_unavailable( - hass: HomeAssistant, tmpdir: py.path.local, mock_config_entry: MockConfigEntry + hass: HomeAssistant, tmp_path: Path, mock_config_entry: MockConfigEntry ) -> None: """Verify we handle state unavailable.""" - testfile = f"{tmpdir}/file.txt" + testfile = str(tmp_path.joinpath("file.txt")) await async_create_file(hass, testfile) - hass.config.allowlist_external_dirs = {tmpdir} + hass.config.allowlist_external_dirs = {tmp_path} mock_config_entry.add_to_hass(hass) hass.config_entries.async_update_entry( mock_config_entry, unique_id=testfile, data={CONF_FILE_PATH: testfile} From 2f7c5a56eb265dac7c38dfc0914185b48dfcd704 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 11 Apr 2023 09:18:16 +0200 Subject: [PATCH 2/4] Use tmp_path in recorder tests (#91202) --- .../statistics/test_duplicates.py | 14 +++++--- tests/components/recorder/test_init.py | 21 +++++++----- .../recorder/test_statistics_v23_migration.py | 32 +++++++++++-------- tests/components/recorder/test_util.py | 7 ++-- .../components/recorder/test_v32_migration.py | 16 ++++++---- 5 files changed, 53 insertions(+), 37 deletions(-) diff --git a/tests/components/recorder/auto_repairs/statistics/test_duplicates.py b/tests/components/recorder/auto_repairs/statistics/test_duplicates.py index 53dac0b6ab2..98f46cadf03 100644 --- a/tests/components/recorder/auto_repairs/statistics/test_duplicates.py +++ b/tests/components/recorder/auto_repairs/statistics/test_duplicates.py @@ -3,10 +3,10 @@ from collections.abc import Callable # pylint: disable=invalid-name import importlib +from pathlib import Path import sys from unittest.mock import patch -import py import pytest from sqlalchemy import create_engine from sqlalchemy.orm import Session @@ -129,10 +129,12 @@ def _create_engine_28(*args, **kwargs): def test_delete_metadata_duplicates( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local + caplog: pytest.LogCaptureFixture, tmp_path: Path ) -> None: """Test removal of duplicated statistics.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" module = "tests.components.recorder.db_schema_28" @@ -222,10 +224,12 @@ def test_delete_metadata_duplicates( def test_delete_metadata_duplicates_many( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local + caplog: pytest.LogCaptureFixture, tmp_path: Path ) -> None: """Test removal of duplicated statistics.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" module = "tests.components.recorder.db_schema_28" diff --git a/tests/components/recorder/test_init.py b/tests/components/recorder/test_init.py index 7a8dc20ad84..466622b72bd 100644 --- a/tests/components/recorder/test_init.py +++ b/tests/components/recorder/test_init.py @@ -11,7 +11,6 @@ from typing import cast from unittest.mock import Mock, patch from freezegun.api import FrozenDateTimeFactory -import py import pytest from sqlalchemy.exc import DatabaseError, OperationalError, SQLAlchemyError @@ -1280,11 +1279,13 @@ def test_statistics_runs_initiated(hass_recorder: Callable[..., HomeAssistant]) @pytest.mark.freeze_time("2022-09-13 09:00:00+02:00") def test_compile_missing_statistics( - tmpdir: py.path.local, freezer: FrozenDateTimeFactory + tmp_path: Path, freezer: FrozenDateTimeFactory ) -> None: """Test missing statistics are compiled on startup.""" now = dt_util.utcnow().replace(minute=0, second=0, microsecond=0) - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" hass = get_test_home_assistant() @@ -1541,9 +1542,11 @@ def test_service_disable_states_not_recording( ) -def test_service_disable_run_information_recorded(tmpdir: py.path.local) -> None: +def test_service_disable_run_information_recorded(tmp_path: Path) -> None: """Test that runs are still recorded when recorder is disabled.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" hass = get_test_home_assistant() @@ -1590,12 +1593,14 @@ class CannotSerializeMe: async def test_database_corruption_while_running( - hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmp_path: Path, caplog: pytest.LogCaptureFixture ) -> None: """Test we can recover from sqlite3 db corruption.""" - def _create_tmpdir_for_test_db(): - return tmpdir.mkdir("sqlite").join("test.db") + def _create_tmpdir_for_test_db() -> Path: + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + return test_dir.joinpath("test.db") test_db_file = await hass.async_add_executor_job(_create_tmpdir_for_test_db) dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" diff --git a/tests/components/recorder/test_statistics_v23_migration.py b/tests/components/recorder/test_statistics_v23_migration.py index efd608811e8..c3d65e7290f 100644 --- a/tests/components/recorder/test_statistics_v23_migration.py +++ b/tests/components/recorder/test_statistics_v23_migration.py @@ -8,10 +8,10 @@ from functools import partial # pylint: disable=invalid-name import importlib import json +from pathlib import Path import sys from unittest.mock import patch -import py import pytest from homeassistant.components import recorder @@ -36,11 +36,11 @@ SCHEMA_VERSION_POSTFIX = "23_with_newer_columns" SCHEMA_MODULE = get_schema_module_path(SCHEMA_VERSION_POSTFIX) -def test_delete_duplicates( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local -) -> None: +def test_delete_duplicates(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None: """Test removal of duplicated statistics.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" importlib.import_module(SCHEMA_MODULE) @@ -215,10 +215,12 @@ def test_delete_duplicates( def test_delete_duplicates_many( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local + caplog: pytest.LogCaptureFixture, tmp_path: Path ) -> None: """Test removal of duplicated statistics.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" importlib.import_module(SCHEMA_MODULE) @@ -400,10 +402,12 @@ def test_delete_duplicates_many( @pytest.mark.freeze_time("2021-08-01 00:00:00+00:00") def test_delete_duplicates_non_identical( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local + caplog: pytest.LogCaptureFixture, tmp_path: Path ) -> None: """Test removal of duplicated statistics.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" importlib.import_module(SCHEMA_MODULE) @@ -529,7 +533,7 @@ def test_delete_duplicates_non_identical( # Test that the duplicates are removed during migration from schema 23 hass = get_test_home_assistant() - hass.config.config_dir = tmpdir + hass.config.config_dir = tmp_path recorder_helper.async_initialize_recorder(hass) setup_component(hass, "recorder", {"recorder": {"db_url": dburl}}) hass.start() @@ -579,10 +583,12 @@ def test_delete_duplicates_non_identical( def test_delete_duplicates_short_term( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local + caplog: pytest.LogCaptureFixture, tmp_path: Path ) -> None: """Test removal of duplicated statistics.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" importlib.import_module(SCHEMA_MODULE) @@ -638,7 +644,7 @@ def test_delete_duplicates_short_term( # Test that the duplicates are removed during migration from schema 23 hass = get_test_home_assistant() - hass.config.config_dir = tmpdir + hass.config.config_dir = tmp_path recorder_helper.async_initialize_recorder(hass) setup_component(hass, "recorder", {"recorder": {"db_url": dburl}}) hass.start() diff --git a/tests/components/recorder/test_util.py b/tests/components/recorder/test_util.py index 4cc4f4b94a8..b78b0a0aaee 100644 --- a/tests/components/recorder/test_util.py +++ b/tests/components/recorder/test_util.py @@ -6,7 +6,6 @@ from pathlib import Path import sqlite3 from unittest.mock import MagicMock, Mock, patch -import py import pytest from sqlalchemy import text from sqlalchemy.engine.result import ChunkedIteratorResult @@ -73,11 +72,11 @@ def test_recorder_bad_execute(hass_recorder: Callable[..., HomeAssistant]) -> No def test_validate_or_move_away_sqlite_database( - hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmp_path: Path, caplog: pytest.LogCaptureFixture ) -> None: """Ensure a malformed sqlite database is moved away.""" - - test_dir = tmpdir.mkdir("test_validate_or_move_away_sqlite_database") + test_dir = tmp_path.joinpath("test_validate_or_move_away_sqlite_database") + test_dir.mkdir() test_db_file = f"{test_dir}/broken.db" dburl = f"{SQLITE_URL_PREFIX}{test_db_file}" diff --git a/tests/components/recorder/test_v32_migration.py b/tests/components/recorder/test_v32_migration.py index 6e424558181..dae4fb39c59 100644 --- a/tests/components/recorder/test_v32_migration.py +++ b/tests/components/recorder/test_v32_migration.py @@ -3,10 +3,10 @@ import asyncio from datetime import timedelta import importlib +from pathlib import Path import sys from unittest.mock import patch -import py import pytest from sqlalchemy import create_engine, inspect from sqlalchemy.orm import Session @@ -52,11 +52,11 @@ def _create_engine_test(*args, **kwargs): return engine -async def test_migrate_times( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local -) -> None: +async def test_migrate_times(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None: """Test we can migrate times.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" importlib.import_module(SCHEMA_MODULE) @@ -225,10 +225,12 @@ async def test_migrate_times( async def test_migrate_can_resume_entity_id_post_migration( - caplog: pytest.LogCaptureFixture, tmpdir: py.path.local + caplog: pytest.LogCaptureFixture, tmp_path: Path ) -> None: """Test we resume the entity id post migration after a restart.""" - test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") + test_dir = tmp_path.joinpath("sqlite") + test_dir.mkdir() + test_db_file = test_dir.joinpath("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" importlib.import_module(SCHEMA_MODULE) From 7b3a932cd94ebbdc245b2186029636864f22a6e5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 11 Apr 2023 10:00:17 +0200 Subject: [PATCH 3/4] Remove incorrect constant usage in test (#91198) --- tests/components/accuweather/test_config_flow.py | 2 +- tests/components/aemet/test_config_flow.py | 2 +- tests/components/airly/test_config_flow.py | 2 +- tests/components/airzone/test_config_flow.py | 4 ++-- tests/components/apcupsd/test_config_flow.py | 2 +- tests/components/awair/test_config_flow.py | 2 +- tests/components/axis/test_config_flow.py | 14 +++++++------- tests/components/balboa/test_config_flow.py | 3 +-- tests/components/braviatv/test_config_flow.py | 2 +- tests/components/brother/test_config_flow.py | 2 +- tests/components/bsblan/test_config_flow.py | 2 +- tests/components/cpuspeed/test_config_flow.py | 4 ++-- tests/components/easyenergy/test_config_flow.py | 2 +- tests/components/econet/test_config_flow.py | 8 ++++---- tests/components/elgato/test_config_flow.py | 2 +- tests/components/energyzero/test_config_flow.py | 2 +- .../components/forecast_solar/test_config_flow.py | 2 +- tests/components/forked_daapd/test_config_flow.py | 2 +- tests/components/freedompro/test_config_flow.py | 2 +- tests/components/fully_kiosk/test_config_flow.py | 4 ++-- tests/components/iss/test_config_flow.py | 2 +- .../components/launch_library/test_config_flow.py | 2 +- tests/components/luftdaten/test_config_flow.py | 12 ++++++------ tests/components/mjpeg/test_config_flow.py | 12 ++++++------ tests/components/moon/test_config_flow.py | 2 +- tests/components/nam/test_config_flow.py | 4 ++-- tests/components/nextdns/test_config_flow.py | 2 +- tests/components/open_meteo/test_config_flow.py | 2 +- .../components/openweathermap/test_config_flow.py | 2 +- tests/components/p1_monitor/test_config_flow.py | 2 +- tests/components/poolsense/test_config_flow.py | 2 +- tests/components/pure_energie/test_config_flow.py | 2 +- tests/components/pvoutput/test_config_flow.py | 6 +++--- tests/components/qnap_qsw/test_config_flow.py | 2 +- tests/components/rdw/test_config_flow.py | 6 +++--- tests/components/season/test_config_flow.py | 2 +- tests/components/stookalert/test_config_flow.py | 2 +- tests/components/stookwijzer/test_config_flow.py | 2 +- tests/components/sun/test_config_flow.py | 2 +- tests/components/tailscale/test_config_flow.py | 6 +++--- tests/components/tolo/test_config_flow.py | 6 +++--- tests/components/twentemilieu/test_config_flow.py | 8 ++++---- tests/components/unifi/test_config_flow.py | 4 ++-- tests/components/uptime/test_config_flow.py | 2 +- tests/components/venstar/test_config_flow.py | 3 +-- tests/components/whois/test_config_flow.py | 6 +++--- tests/components/youless/test_config_flows.py | 4 ++-- 47 files changed, 85 insertions(+), 87 deletions(-) diff --git a/tests/components/accuweather/test_config_flow.py b/tests/components/accuweather/test_config_flow.py index a6a9f9c04fc..4d8d83a2a2f 100644 --- a/tests/components/accuweather/test_config_flow.py +++ b/tests/components/accuweather/test_config_flow.py @@ -26,7 +26,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_api_key_too_short(hass: HomeAssistant) -> None: diff --git a/tests/components/aemet/test_config_flow.py b/tests/components/aemet/test_config_flow.py index 8ec16d313f7..59a6993903f 100644 --- a/tests/components/aemet/test_config_flow.py +++ b/tests/components/aemet/test_config_flow.py @@ -36,7 +36,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/airly/test_config_flow.py b/tests/components/airly/test_config_flow.py index 8a9b8807a19..2abd9bd1204 100644 --- a/tests/components/airly/test_config_flow.py +++ b/tests/components/airly/test_config_flow.py @@ -29,7 +29,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_invalid_api_key( diff --git a/tests/components/airzone/test_config_flow.py b/tests/components/airzone/test_config_flow.py index 1501c9ba863..2d89d0b556e 100644 --- a/tests/components/airzone/test_config_flow.py +++ b/tests/components/airzone/test_config_flow.py @@ -54,7 +54,7 @@ async def test_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( @@ -97,7 +97,7 @@ async def test_form_invalid_system_id(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {CONF_ID: "invalid_system_id"} mock_hvac.return_value = HVAC_MOCK[API_SYSTEMS][0] diff --git a/tests/components/apcupsd/test_config_flow.py b/tests/components/apcupsd/test_config_flow.py index c8696c71941..a9ef4328e86 100644 --- a/tests/components/apcupsd/test_config_flow.py +++ b/tests/components/apcupsd/test_config_flow.py @@ -117,7 +117,7 @@ async def test_flow_works(hass: HomeAssistant) -> None: context={CONF_SOURCE: SOURCE_USER}, ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=CONF_DATA diff --git a/tests/components/awair/test_config_flow.py b/tests/components/awair/test_config_flow.py index 5a1a83fa0fb..b9f466174af 100644 --- a/tests/components/awair/test_config_flow.py +++ b/tests/components/awair/test_config_flow.py @@ -29,7 +29,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.MENU - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_invalid_access_token(hass: HomeAssistant) -> None: diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index 2c5b3a50513..d535b4bcb1f 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -56,7 +56,7 @@ async def test_flow_manual_configuration( ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -91,7 +91,7 @@ async def test_manual_configuration_update_configuration( ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" mock_vapix_requests("2.3.4.5") result = await hass.config_entries.flow.async_configure( @@ -117,7 +117,7 @@ async def test_flow_fails_faulty_credentials(hass: HomeAssistant) -> None: ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "homeassistant.components.axis.config_flow.get_axis_device", @@ -143,7 +143,7 @@ async def test_flow_fails_cannot_connect(hass: HomeAssistant) -> None: ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "homeassistant.components.axis.config_flow.get_axis_device", @@ -182,7 +182,7 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model( ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -223,7 +223,7 @@ async def test_reauth_flow_update_configuration( ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" mock_vapix_requests("2.3.4.5") result = await hass.config_entries.flow.async_configure( @@ -321,7 +321,7 @@ async def test_discovery_flow( ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" flows = hass.config_entries.flow.async_progress() assert len(flows) == 1 diff --git a/tests/components/balboa/test_config_flow.py b/tests/components/balboa/test_config_flow.py index 44ead926e46..95c415b8909 100644 --- a/tests/components/balboa/test_config_flow.py +++ b/tests/components/balboa/test_config_flow.py @@ -5,7 +5,6 @@ from pybalboa.exceptions import SpaConnectionError from homeassistant import config_entries, data_entry_flow from homeassistant.components.balboa.const import CONF_SYNC_TIME, DOMAIN -from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -111,7 +110,7 @@ async def test_already_configured(hass: HomeAssistant, client: MagicMock) -> Non ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "homeassistant.components.balboa.config_flow.SpaClient.__aenter__", diff --git a/tests/components/braviatv/test_config_flow.py b/tests/components/braviatv/test_config_flow.py index 3dffeaf527c..1ac1fcd4bea 100644 --- a/tests/components/braviatv/test_config_flow.py +++ b/tests/components/braviatv/test_config_flow.py @@ -94,7 +94,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_ssdp_discovery(hass: HomeAssistant) -> None: diff --git a/tests/components/brother/test_config_flow.py b/tests/components/brother/test_config_flow.py index 0e1db72ddae..629295e09e0 100644 --- a/tests/components/brother/test_config_flow.py +++ b/tests/components/brother/test_config_flow.py @@ -26,7 +26,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_create_entry_with_hostname(hass: HomeAssistant) -> None: diff --git a/tests/components/bsblan/test_config_flow.py b/tests/components/bsblan/test_config_flow.py index ab8d4237588..bcd6dec14b1 100644 --- a/tests/components/bsblan/test_config_flow.py +++ b/tests/components/bsblan/test_config_flow.py @@ -31,7 +31,7 @@ async def test_full_user_flow_implementation( ) assert result.get("type") == RESULT_TYPE_FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/cpuspeed/test_config_flow.py b/tests/components/cpuspeed/test_config_flow.py index 2d0f4c6df22..323eb80d712 100644 --- a/tests/components/cpuspeed/test_config_flow.py +++ b/tests/components/cpuspeed/test_config_flow.py @@ -21,7 +21,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -67,7 +67,7 @@ async def test_not_compatible( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_cpuinfo_config_flow.return_value = {} result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/easyenergy/test_config_flow.py b/tests/components/easyenergy/test_config_flow.py index 2ad9b762e83..30d4924db8c 100644 --- a/tests/components/easyenergy/test_config_flow.py +++ b/tests/components/easyenergy/test_config_flow.py @@ -17,7 +17,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" assert "flow_id" in result result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/econet/test_config_flow.py b/tests/components/econet/test_config_flow.py index 6048aea17c0..d01d6163285 100644 --- a/tests/components/econet/test_config_flow.py +++ b/tests/components/econet/test_config_flow.py @@ -20,7 +20,7 @@ async def test_bad_credentials(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "pyeconet.EcoNetApiInterface.login", @@ -50,7 +50,7 @@ async def test_generic_error_from_library(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "pyeconet.EcoNetApiInterface.login", @@ -80,7 +80,7 @@ async def test_auth_worked(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "pyeconet.EcoNetApiInterface.login", @@ -117,7 +117,7 @@ async def test_already_configured(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "pyeconet.EcoNetApiInterface.login", diff --git a/tests/components/elgato/test_config_flow.py b/tests/components/elgato/test_config_flow.py index 3447038b778..1b71a29632f 100644 --- a/tests/components/elgato/test_config_flow.py +++ b/tests/components/elgato/test_config_flow.py @@ -28,7 +28,7 @@ async def test_full_user_flow_implementation( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_HOST: "127.0.0.1", CONF_PORT: 9123} diff --git a/tests/components/energyzero/test_config_flow.py b/tests/components/energyzero/test_config_flow.py index c24eed9b259..5f7b4925036 100644 --- a/tests/components/energyzero/test_config_flow.py +++ b/tests/components/energyzero/test_config_flow.py @@ -20,7 +20,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" assert "flow_id" in result result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/forecast_solar/test_config_flow.py b/tests/components/forecast_solar/test_config_flow.py index 41cfb4d839e..2129821217e 100644 --- a/tests/components/forecast_solar/test_config_flow.py +++ b/tests/components/forecast_solar/test_config_flow.py @@ -24,7 +24,7 @@ async def test_user_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/forked_daapd/test_config_flow.py b/tests/components/forked_daapd/test_config_flow.py index fe442641e72..81357b6f3eb 100644 --- a/tests/components/forked_daapd/test_config_flow.py +++ b/tests/components/forked_daapd/test_config_flow.py @@ -60,7 +60,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_config_flow(hass: HomeAssistant, config_entry) -> None: diff --git a/tests/components/freedompro/test_config_flow.py b/tests/components/freedompro/test_config_flow.py index dc55ba037ba..cab8605d865 100644 --- a/tests/components/freedompro/test_config_flow.py +++ b/tests/components/freedompro/test_config_flow.py @@ -25,7 +25,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_invalid_auth(hass: HomeAssistant) -> None: diff --git a/tests/components/fully_kiosk/test_config_flow.py b/tests/components/fully_kiosk/test_config_flow.py index 5527cd367af..566f3b6d292 100644 --- a/tests/components/fully_kiosk/test_config_flow.py +++ b/tests/components/fully_kiosk/test_config_flow.py @@ -28,7 +28,7 @@ async def test_user_flow( DOMAIN, context={"source": SOURCE_USER} ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -117,7 +117,7 @@ async def test_duplicate_updates_existing_entry( DOMAIN, context={"source": SOURCE_USER} ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/iss/test_config_flow.py b/tests/components/iss/test_config_flow.py index f206f5d8580..fec4d9b192c 100644 --- a/tests/components/iss/test_config_flow.py +++ b/tests/components/iss/test_config_flow.py @@ -18,7 +18,7 @@ async def test_create_entry(hass: HomeAssistant) -> None: ) assert result.get("type") == data_entry_flow.FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" with patch("homeassistant.components.iss.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/launch_library/test_config_flow.py b/tests/components/launch_library/test_config_flow.py index ef88c4d1bb6..8a8a2a94937 100644 --- a/tests/components/launch_library/test_config_flow.py +++ b/tests/components/launch_library/test_config_flow.py @@ -17,7 +17,7 @@ async def test_create_entry(hass: HomeAssistant) -> None: ) assert result.get("type") == data_entry_flow.FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" with patch( "homeassistant.components.launch_library.async_setup_entry", return_value=True diff --git a/tests/components/luftdaten/test_config_flow.py b/tests/components/luftdaten/test_config_flow.py index d98e415482d..5197a101bfd 100644 --- a/tests/components/luftdaten/test_config_flow.py +++ b/tests/components/luftdaten/test_config_flow.py @@ -24,7 +24,7 @@ async def test_duplicate_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -44,7 +44,7 @@ async def test_communication_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_luftdaten_config_flow.get_data.side_effect = LuftdatenConnectionError result2 = await hass.config_entries.flow.async_configure( @@ -53,7 +53,7 @@ async def test_communication_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {CONF_SENSOR_ID: "cannot_connect"} mock_luftdaten_config_flow.get_data.side_effect = None @@ -79,7 +79,7 @@ async def test_invalid_sensor( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_luftdaten_config_flow.validate_sensor.return_value = False result2 = await hass.config_entries.flow.async_configure( @@ -88,7 +88,7 @@ async def test_invalid_sensor( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {CONF_SENSOR_ID: "invalid_sensor"} mock_luftdaten_config_flow.validate_sensor.return_value = True @@ -116,7 +116,7 @@ async def test_step_user( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/mjpeg/test_config_flow.py b/tests/components/mjpeg/test_config_flow.py index c95f4f1c40f..a60df88b789 100644 --- a/tests/components/mjpeg/test_config_flow.py +++ b/tests/components/mjpeg/test_config_flow.py @@ -36,7 +36,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -81,7 +81,7 @@ async def test_full_flow_with_authentication_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_mjpeg_requests.get( "https://example.com/mjpeg", text="Access Denied!", status_code=401 @@ -97,7 +97,7 @@ async def test_full_flow_with_authentication_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"username": "invalid_auth"} assert len(mock_setup_entry.mock_calls) == 0 @@ -141,7 +141,7 @@ async def test_connection_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" # Test connectione error on MJPEG url mock_mjpeg_requests.get( @@ -157,7 +157,7 @@ async def test_connection_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"mjpeg_url": "cannot_connect"} assert len(mock_setup_entry.mock_calls) == 0 @@ -180,7 +180,7 @@ async def test_connection_error( ) assert result3.get("type") == FlowResultType.FORM - assert result3.get("step_id") == SOURCE_USER + assert result3.get("step_id") == "user" assert result3.get("errors") == {"still_image_url": "cannot_connect"} assert len(mock_setup_entry.mock_calls) == 0 diff --git a/tests/components/moon/test_config_flow.py b/tests/components/moon/test_config_flow.py index e7ee1cceefd..cd2ab94fefc 100644 --- a/tests/components/moon/test_config_flow.py +++ b/tests/components/moon/test_config_flow.py @@ -19,7 +19,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/nam/test_config_flow.py b/tests/components/nam/test_config_flow.py index 9aafcae2482..78a96e148ce 100644 --- a/tests/components/nam/test_config_flow.py +++ b/tests/components/nam/test_config_flow.py @@ -34,7 +34,7 @@ async def test_form_create_entry_without_auth(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} with patch( @@ -64,7 +64,7 @@ async def test_form_create_entry_with_auth(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} with patch( diff --git a/tests/components/nextdns/test_config_flow.py b/tests/components/nextdns/test_config_flow.py index 07591ed2bbf..b5d718b61aa 100644 --- a/tests/components/nextdns/test_config_flow.py +++ b/tests/components/nextdns/test_config_flow.py @@ -24,7 +24,7 @@ async def test_form_create_entry(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} with patch( diff --git a/tests/components/open_meteo/test_config_flow.py b/tests/components/open_meteo/test_config_flow.py index c81d4da8c91..2eda6a8192b 100644 --- a/tests/components/open_meteo/test_config_flow.py +++ b/tests/components/open_meteo/test_config_flow.py @@ -20,7 +20,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/openweathermap/test_config_flow.py b/tests/components/openweathermap/test_config_flow.py index 28ba175cbef..2bd62936fe5 100644 --- a/tests/components/openweathermap/test_config_flow.py +++ b/tests/components/openweathermap/test_config_flow.py @@ -47,7 +47,7 @@ async def test_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} result = await hass.config_entries.flow.async_init( diff --git a/tests/components/p1_monitor/test_config_flow.py b/tests/components/p1_monitor/test_config_flow.py index 98dfe184c13..419f24871ef 100644 --- a/tests/components/p1_monitor/test_config_flow.py +++ b/tests/components/p1_monitor/test_config_flow.py @@ -17,7 +17,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None: ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" with patch( "homeassistant.components.p1_monitor.config_flow.P1Monitor.smartmeter" diff --git a/tests/components/poolsense/test_config_flow.py b/tests/components/poolsense/test_config_flow.py index 6b3a8f7ea6f..71303e48dbf 100644 --- a/tests/components/poolsense/test_config_flow.py +++ b/tests/components/poolsense/test_config_flow.py @@ -15,7 +15,7 @@ async def test_show_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" async def test_invalid_credentials(hass: HomeAssistant) -> None: diff --git a/tests/components/pure_energie/test_config_flow.py b/tests/components/pure_energie/test_config_flow.py index ebd7aefff20..2b00e975a8e 100644 --- a/tests/components/pure_energie/test_config_flow.py +++ b/tests/components/pure_energie/test_config_flow.py @@ -22,7 +22,7 @@ async def test_full_user_flow_implementation( context={"source": SOURCE_USER}, ) - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" assert result.get("type") == FlowResultType.FORM result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/pvoutput/test_config_flow.py b/tests/components/pvoutput/test_config_flow.py index 36a783f86fb..bf05afa020d 100644 --- a/tests/components/pvoutput/test_config_flow.py +++ b/tests/components/pvoutput/test_config_flow.py @@ -24,7 +24,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -60,7 +60,7 @@ async def test_full_flow_with_authentication_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_pvoutput_config_flow.system.side_effect = PVOutputAuthenticationError result2 = await hass.config_entries.flow.async_configure( @@ -72,7 +72,7 @@ async def test_full_flow_with_authentication_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"base": "invalid_auth"} assert len(mock_setup_entry.mock_calls) == 0 diff --git a/tests/components/qnap_qsw/test_config_flow.py b/tests/components/qnap_qsw/test_config_flow.py index 7c2153d5f90..ab35a9369ea 100644 --- a/tests/components/qnap_qsw/test_config_flow.py +++ b/tests/components/qnap_qsw/test_config_flow.py @@ -49,7 +49,7 @@ async def test_form(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/rdw/test_config_flow.py b/tests/components/rdw/test_config_flow.py index 8dc0dac8b9d..b8c21be300e 100644 --- a/tests/components/rdw/test_config_flow.py +++ b/tests/components/rdw/test_config_flow.py @@ -19,7 +19,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -46,7 +46,7 @@ async def test_full_flow_with_authentication_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_rdw_config_flow.vehicle.side_effect = RDWUnknownLicensePlateError result2 = await hass.config_entries.flow.async_configure( @@ -57,7 +57,7 @@ async def test_full_flow_with_authentication_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"base": "unknown_license_plate"} mock_rdw_config_flow.vehicle.side_effect = None diff --git a/tests/components/season/test_config_flow.py b/tests/components/season/test_config_flow.py index 6579bb53a9b..884c5a3ddc8 100644 --- a/tests/components/season/test_config_flow.py +++ b/tests/components/season/test_config_flow.py @@ -20,7 +20,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/stookalert/test_config_flow.py b/tests/components/stookalert/test_config_flow.py index aeff4b01de9..0014f4e5ad5 100644 --- a/tests/components/stookalert/test_config_flow.py +++ b/tests/components/stookalert/test_config_flow.py @@ -16,7 +16,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None: ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" with patch( "homeassistant.components.stookalert.async_setup_entry", return_value=True diff --git a/tests/components/stookwijzer/test_config_flow.py b/tests/components/stookwijzer/test_config_flow.py index b18eb54b322..90786659254 100644 --- a/tests/components/stookwijzer/test_config_flow.py +++ b/tests/components/stookwijzer/test_config_flow.py @@ -15,7 +15,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None: ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" assert "flow_id" in result with patch( diff --git a/tests/components/sun/test_config_flow.py b/tests/components/sun/test_config_flow.py index 2d4e2d83249..2bf577f82b8 100644 --- a/tests/components/sun/test_config_flow.py +++ b/tests/components/sun/test_config_flow.py @@ -18,7 +18,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None: ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" with patch( "homeassistant.components.sun.async_setup_entry", diff --git a/tests/components/tailscale/test_config_flow.py b/tests/components/tailscale/test_config_flow.py index 45e3e85d878..5bf814a56d6 100644 --- a/tests/components/tailscale/test_config_flow.py +++ b/tests/components/tailscale/test_config_flow.py @@ -24,7 +24,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -60,7 +60,7 @@ async def test_full_flow_with_authentication_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_tailscale_config_flow.devices.side_effect = TailscaleAuthenticationError result2 = await hass.config_entries.flow.async_configure( @@ -72,7 +72,7 @@ async def test_full_flow_with_authentication_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"base": "invalid_auth"} assert len(mock_setup_entry.mock_calls) == 0 diff --git a/tests/components/tolo/test_config_flow.py b/tests/components/tolo/test_config_flow.py index 649a21f5bcf..aa88766c395 100644 --- a/tests/components/tolo/test_config_flow.py +++ b/tests/components/tolo/test_config_flow.py @@ -34,7 +34,7 @@ async def test_user_with_timed_out_host(hass: HomeAssistant, toloclient: Mock) - ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" assert result["errors"] == {"base": "cannot_connect"} @@ -45,7 +45,7 @@ async def test_user_walkthrough(hass: HomeAssistant, toloclient: Mock) -> None: ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" toloclient().get_status_info.side_effect = lambda *args, **kwargs: None @@ -55,7 +55,7 @@ async def test_user_walkthrough(hass: HomeAssistant, toloclient: Mock) -> None: ) assert result2["type"] == FlowResultType.FORM - assert result2["step_id"] == SOURCE_USER + assert result2["step_id"] == "user" assert result2["errors"] == {"base": "cannot_connect"} toloclient().get_status_info.side_effect = lambda *args, **kwargs: object() diff --git a/tests/components/twentemilieu/test_config_flow.py b/tests/components/twentemilieu/test_config_flow.py index d8c2c82f4eb..e5875ecaab7 100644 --- a/tests/components/twentemilieu/test_config_flow.py +++ b/tests/components/twentemilieu/test_config_flow.py @@ -30,7 +30,7 @@ async def test_full_user_flow(hass: HomeAssistant, snapshot: SnapshotAssertion) ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -60,7 +60,7 @@ async def test_invalid_address( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_twentemilieu.unique_id.side_effect = TwenteMilieuAddressError result2 = await hass.config_entries.flow.async_configure( @@ -72,7 +72,7 @@ async def test_invalid_address( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"base": "invalid_address"} mock_twentemilieu.unique_id.side_effect = None @@ -106,7 +106,7 @@ async def test_connection_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" assert result.get("errors") == {"base": "cannot_connect"} diff --git a/tests/components/unifi/test_config_flow.py b/tests/components/unifi/test_config_flow.py index 0d358ef5149..d91771322f3 100644 --- a/tests/components/unifi/test_config_flow.py +++ b/tests/components/unifi/test_config_flow.py @@ -21,7 +21,7 @@ from homeassistant.components.unifi.const import ( CONF_TRACK_WIRED_CLIENTS, DOMAIN as UNIFI_DOMAIN, ) -from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER +from homeassistant.config_entries import SOURCE_REAUTH from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -398,7 +398,7 @@ async def test_reauth_flow_update_configuration( ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" aioclient_mock.clear_requests() diff --git a/tests/components/uptime/test_config_flow.py b/tests/components/uptime/test_config_flow.py index 9f1c3931d18..a2234882b27 100644 --- a/tests/components/uptime/test_config_flow.py +++ b/tests/components/uptime/test_config_flow.py @@ -22,7 +22,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/venstar/test_config_flow.py b/tests/components/venstar/test_config_flow.py index f8f66f1b388..521e5a8512e 100644 --- a/tests/components/venstar/test_config_flow.py +++ b/tests/components/venstar/test_config_flow.py @@ -4,7 +4,6 @@ from unittest.mock import patch from homeassistant import config_entries from homeassistant.components.venstar.const import DOMAIN -from homeassistant.config_entries import SOURCE_USER from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -105,7 +104,7 @@ async def test_already_configured(hass: HomeAssistant) -> None: ) assert result["type"] == FlowResultType.FORM - assert result["step_id"] == SOURCE_USER + assert result["step_id"] == "user" with patch( "homeassistant.components.venstar.VenstarColorTouch.update_info", diff --git a/tests/components/whois/test_config_flow.py b/tests/components/whois/test_config_flow.py index 52bb87817f2..91aa207d60f 100644 --- a/tests/components/whois/test_config_flow.py +++ b/tests/components/whois/test_config_flow.py @@ -31,7 +31,7 @@ async def test_full_user_flow( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -71,7 +71,7 @@ async def test_full_flow_with_error( ) assert result.get("type") == FlowResultType.FORM - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_whois.side_effect = throw result2 = await hass.config_entries.flow.async_configure( @@ -80,7 +80,7 @@ async def test_full_flow_with_error( ) assert result2.get("type") == FlowResultType.FORM - assert result2.get("step_id") == SOURCE_USER + assert result2.get("step_id") == "user" assert result2.get("errors") == {"base": reason} assert len(mock_setup_entry.mock_calls) == 0 diff --git a/tests/components/youless/test_config_flows.py b/tests/components/youless/test_config_flows.py index 08f38f8eb2c..6512103cde0 100644 --- a/tests/components/youless/test_config_flows.py +++ b/tests/components/youless/test_config_flows.py @@ -27,7 +27,7 @@ async def test_full_flow(hass: HomeAssistant) -> None: assert result.get("type") == FlowResultType.FORM assert result.get("errors") == {} - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_youless = _get_mock_youless_api( initialize={"homes": [{"id": 1, "name": "myhome"}]} @@ -54,7 +54,7 @@ async def test_not_found(hass: HomeAssistant) -> None: assert result.get("type") == FlowResultType.FORM assert result.get("errors") == {} - assert result.get("step_id") == SOURCE_USER + assert result.get("step_id") == "user" mock_youless = _get_mock_youless_api(initialize=URLError("")) with patch( From 95109072b523d47525421ee5f136a5ff23dd7e99 Mon Sep 17 00:00:00 2001 From: Avi Miller Date: Tue, 11 Apr 2023 18:09:53 +1000 Subject: [PATCH 4/4] Remove myself as a codeowner of the LIFX integration (#91143) --- CODEOWNERS | 4 ++-- homeassistant/components/lifx/manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 906787e0452..71a354042c0 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -649,8 +649,8 @@ build.json @home-assistant/supervisor /tests/components/lidarr/ @tkdrob /homeassistant/components/life360/ @pnbruckner /tests/components/life360/ @pnbruckner -/homeassistant/components/lifx/ @bdraco @Djelibeybi -/tests/components/lifx/ @bdraco @Djelibeybi +/homeassistant/components/lifx/ @bdraco +/tests/components/lifx/ @bdraco /homeassistant/components/light/ @home-assistant/core /tests/components/light/ @home-assistant/core /homeassistant/components/linux_battery/ @fabaff diff --git a/homeassistant/components/lifx/manifest.json b/homeassistant/components/lifx/manifest.json index 65f4e7ecefa..467c4e31669 100644 --- a/homeassistant/components/lifx/manifest.json +++ b/homeassistant/components/lifx/manifest.json @@ -1,7 +1,7 @@ { "domain": "lifx", "name": "LIFX", - "codeowners": ["@bdraco", "@Djelibeybi"], + "codeowners": ["@bdraco"], "config_flow": true, "dependencies": ["network"], "dhcp": [