Merge branch 'dev' into single_history_query

This commit is contained in:
J. Nick Koston
2023-04-10 22:29:30 -10:00
committed by GitHub
59 changed files with 190 additions and 187 deletions

View File

@@ -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

View File

@@ -1,7 +1,7 @@
{
"domain": "lifx",
"name": "LIFX",
"codeowners": ["@bdraco", "@Djelibeybi"],
"codeowners": ["@bdraco"],
"config_flow": true,
"dependencies": ["network"],
"dhcp": [

View File

@@ -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:

View File

@@ -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(

View File

@@ -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(

View File

@@ -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]

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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__",

View File

@@ -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:

View File

@@ -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:

View File

@@ -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"],

View File

@@ -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(

View File

@@ -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(

View File

@@ -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",

View File

@@ -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}

View File

@@ -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(

View File

@@ -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:

View File

@@ -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)

View File

@@ -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,
}

View File

@@ -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(

View File

@@ -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}

View File

@@ -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"],

View File

@@ -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:

View File

@@ -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:

View File

@@ -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"],

View File

@@ -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(

View File

@@ -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

View File

@@ -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"],

View File

@@ -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

View File

@@ -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"],

View File

@@ -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(

View File

@@ -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(

View File

@@ -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"],

View File

@@ -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(

View File

@@ -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"

View File

@@ -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:

View File

@@ -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(

View File

@@ -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

View File

@@ -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(

View File

@@ -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

View File

@@ -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"

View File

@@ -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}"

View File

@@ -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()

View File

@@ -6,7 +6,6 @@ from pathlib import Path
import sqlite3
from unittest.mock import MagicMock, Mock, patch
import py
import pytest
from sqlalchemy import lambda_stmt, 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}"

View File

@@ -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)

View File

@@ -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"],

View File

@@ -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

View File

@@ -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(

View File

@@ -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",

View File

@@ -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

View File

@@ -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()

View File

@@ -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"}

View File

@@ -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()

View File

@@ -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"],

View File

@@ -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",

View File

@@ -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

View File

@@ -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(