Compare commits

...

24 Commits

Author SHA1 Message Date
Franck Nijhof
0e1d1fbaed Fix fixture ordering in jvc_projector integration setup (#164354) 2026-02-27 20:41:17 +01:00
Franck Nijhof
57d7f364f4 Mock async_setup_entry in wilight SSDP flow test (#164393) 2026-02-27 20:40:35 +01:00
Franck Nijhof
7cc5777b47 Fix fixture ordering in madVR tests to ensure proper mocking (#164350) 2026-02-27 20:38:42 +01:00
Franck Nijhof
5e3f23b6a2 Fix mock target for Met Office config flow error test (#164391) 2026-02-27 20:37:24 +01:00
Franck Nijhof
6873a40407 Mock async_setup_entry in forked_daapd config flow tests (#164370) 2026-02-27 20:36:33 +01:00
Franck Nijhof
ddaa2fb293 Mock async_setup_entry in daikin config flow tests (#164371) 2026-02-27 20:36:23 +01:00
Franck Nijhof
53b6223459 Mock async_setup_entry in emulated_roku config flow tests (#164368) 2026-02-27 20:35:50 +01:00
Franck Nijhof
7329cfb927 Mock async_setup_entry in home_connect migration tests (#164357) 2026-02-27 20:33:54 +01:00
Franck Nijhof
44b80dde0c Mock async_setup_entry in radarr config flow tests (#164359) 2026-02-27 20:33:19 +01:00
Joost Lekkerkerker
8c125e4e4f Add do not disturb switch to SmartThings (#164364) 2026-02-27 20:31:56 +01:00
Franck Nijhof
227a258382 Add missing client mocks to tplink_omada service tests (#164389) 2026-02-27 20:30:54 +01:00
Franck Nijhof
addc2a6766 Mock async_setup_entry in speedtestdotnet config flow test (#164387) 2026-02-27 20:30:47 +01:00
Franck Nijhof
97bcea9727 Mock async_setup_entry in tautulli config flow tests (#164388) 2026-02-27 20:30:38 +01:00
Franck Nijhof
4f05c807b0 Mock async_setup_entry in panasonic_viera config flow tests (#164385) 2026-02-27 20:30:25 +01:00
Franck Nijhof
177a918c26 Mock async_setup_entry in onvif DHCP host update test (#164384) 2026-02-27 20:30:15 +01:00
Franck Nijhof
9705770c6c Remove unnecessary config entry from velux validation error test (#164383) 2026-02-27 20:30:12 +01:00
Franck Nijhof
7309351165 Mock async_setup_entry in lunatone config flow tests (#164382) 2026-02-27 20:29:22 +01:00
Franck Nijhof
d0401de70d Mock HMConnection in homematic notify tests (#164381) 2026-02-27 20:29:14 +01:00
Franck Nijhof
6b89359a73 Mock async_setup_entry in sharkiq setup test (#164380) 2026-02-27 20:27:40 +01:00
Franck Nijhof
b31bafab99 Mock async_setup_entry in roku options flow test (#164377) 2026-02-27 20:27:13 +01:00
Franck Nijhof
84c556bb63 Mock setup and client in sma config flow tests (#164374) 2026-02-27 20:26:59 +01:00
Franck Nijhof
225ea02d9a Fix axis setup failure test to mock at correct layer (#164373) 2026-02-27 20:26:46 +01:00
Franck Nijhof
ebd1cc994c Add missing mock_transmission_client to transmission init tests (#164369) 2026-02-27 20:26:33 +01:00
Franck Nijhof
9ec22ba158 Mock async_setup_entry in kostal_plenticore reconfigure test (#164372) 2026-02-27 20:26:18 +01:00
30 changed files with 305 additions and 70 deletions

View File

@@ -177,6 +177,12 @@
"on": "mdi:lightbulb-on"
}
},
"do_not_disturb": {
"default": "mdi:minus-circle-off",
"state": {
"on": "mdi:minus-circle"
}
},
"dry_plus": {
"default": "mdi:heat-wave"
},

View File

@@ -859,6 +859,9 @@
"display_lighting": {
"name": "Display lighting"
},
"do_not_disturb": {
"name": "Do not disturb"
},
"dry_plus": {
"name": "Dry plus"
},

View File

@@ -162,6 +162,14 @@ CAPABILITY_TO_SWITCHES: dict[Capability | str, SmartThingsSwitchEntityDescriptio
status_attribute=Attribute.STATUS,
entity_category=EntityCategory.CONFIG,
),
Capability.CUSTOM_DO_NOT_DISTURB_MODE: SmartThingsSwitchEntityDescription(
key=Capability.CUSTOM_DO_NOT_DISTURB_MODE,
translation_key="do_not_disturb",
status_attribute=Attribute.DO_NOT_DISTURB,
entity_category=EntityCategory.CONFIG,
on_command=Command.DO_NOT_DISTURB_ON,
off_command=Command.DO_NOT_DISTURB_OFF,
),
}
DISHWASHER_WASHING_OPTIONS_TO_SWITCHES: dict[
Attribute | str, SmartThingsDishwasherWashingOptionSwitchEntityDescription

View File

@@ -19,18 +19,16 @@ async def test_setup_entry(config_entry_setup: MockConfigEntry) -> None:
async def test_setup_entry_fails(
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Test successful setup of entry."""
"""Test failed setup of entry."""
config_entry.add_to_hass(hass)
mock_device = Mock()
mock_device.async_setup = AsyncMock(return_value=False)
with patch(
"homeassistant.components.axis.get_axis_api",
side_effect=axis.CannotConnect,
):
await hass.config_entries.async_setup(config_entry.entry_id)
with patch.object(axis, "AxisHub") as mock_device_class:
mock_device_class.return_value = mock_device
assert not await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state is ConfigEntryState.SETUP_ERROR
assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(

View File

@@ -1,7 +1,8 @@
"""Tests for the Daikin config flow."""
from collections.abc import Generator
from ipaddress import ip_address
from unittest.mock import PropertyMock, patch
from unittest.mock import AsyncMock, PropertyMock, patch
from aiohttp import ClientError, web_exceptions
from pydaikin.exceptions import DaikinException
@@ -20,6 +21,15 @@ MAC = "AABBCCDDEEFF"
HOST = "127.0.0.1"
@pytest.fixture(autouse=True)
def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.daikin.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup
@pytest.fixture
def mock_daikin():
"""Mock pydaikin."""

View File

@@ -1,5 +1,10 @@
"""Tests for emulated_roku config flow."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch
import pytest
from homeassistant import config_entries
from homeassistant.components.emulated_roku import config_flow
from homeassistant.core import HomeAssistant
@@ -8,6 +13,15 @@ from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@pytest.fixture(autouse=True)
def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.emulated_roku.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup
async def test_flow_works(hass: HomeAssistant) -> None:
"""Test that config flow works."""
result = await hass.config_entries.flow.async_init(

View File

@@ -76,6 +76,10 @@ async def test_config_flow(hass: HomeAssistant, config_entry: MockConfigEntry) -
"homeassistant.components.forked_daapd.ForkedDaapdAPI.get_request",
autospec=True,
) as mock_get_request,
patch(
"homeassistant.components.forked_daapd.async_setup_entry",
return_value=True,
),
):
mock_get_request.return_value = SAMPLE_CONFIG
mock_test_connection.return_value = ["ok", "My Music on myhost"]
@@ -229,10 +233,16 @@ async def test_config_flow_zeroconf_valid(hass: HomeAssistant) -> None:
async def test_options_flow(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
"""Test config flow options."""
with patch(
"homeassistant.components.forked_daapd.ForkedDaapdAPI.get_request",
autospec=True,
) as mock_get_request:
with (
patch(
"homeassistant.components.forked_daapd.ForkedDaapdAPI.get_request",
autospec=True,
) as mock_get_request,
patch(
"homeassistant.components.forked_daapd.async_setup_entry",
return_value=True,
),
):
mock_get_request.return_value = SAMPLE_CONFIG
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)

View File

@@ -336,7 +336,13 @@ async def test_entity_migration(
config_entry=config_entry_v1_1,
)
with patch("homeassistant.components.home_connect.PLATFORMS", platforms):
with (
patch("homeassistant.components.home_connect.PLATFORMS", platforms),
patch(
"homeassistant.components.home_connect.async_setup_entry",
return_value=True,
),
):
await hass.config_entries.async_setup(config_entry_v1_1.entry_id)
await hass.async_block_till_done()
@@ -364,8 +370,12 @@ async def test_config_entry_unique_id_migration(
assert config_entry_v1_2.unique_id != "1234567890"
assert config_entry_v1_2.minor_version == 2
await hass.config_entries.async_setup(config_entry_v1_2.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.home_connect.async_setup_entry",
return_value=True,
):
await hass.config_entries.async_setup(config_entry_v1_2.entry_id)
await hass.async_block_till_done()
assert config_entry_v1_2.unique_id == "1234567890"
assert config_entry_v1_2.minor_version == 3

View File

@@ -1,5 +1,7 @@
"""The tests for the Homematic notification platform."""
from unittest.mock import MagicMock, patch
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@@ -9,11 +11,15 @@ from tests.common import assert_setup_component
async def test_setup_full(hass: HomeAssistant) -> None:
"""Test valid configuration."""
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with patch(
"homeassistant.components.homematic.HMConnection",
return_value=MagicMock(),
):
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with assert_setup_component(1, domain="notify") as handle_config:
assert await async_setup_component(
hass,
@@ -35,11 +41,15 @@ async def test_setup_full(hass: HomeAssistant) -> None:
async def test_setup_without_optional(hass: HomeAssistant) -> None:
"""Test valid configuration without optional."""
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with patch(
"homeassistant.components.homematic.HMConnection",
return_value=MagicMock(),
):
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with assert_setup_component(1, domain="notify") as handle_config:
assert await async_setup_component(
hass,

View File

@@ -136,6 +136,7 @@ def fixture_mock_config_entry() -> MockConfigEntry:
async def fixture_mock_integration(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_device: MagicMock,
) -> MockConfigEntry:
"""Return a mock ConfigEntry setup for the integration."""
with (

View File

@@ -400,14 +400,18 @@ async def test_reconfigure(
return_value={"scb:network": {"Hostname": "scb"}}
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"host": "1.1.1.1",
"password": "test-password",
},
)
await hass.async_block_till_done()
with patch(
"homeassistant.components.kostal_plenticore.async_setup_entry",
return_value=True,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"host": "1.1.1.1",
"password": "test-password",
},
)
await hass.async_block_till_done()
mock_apiclient_class.assert_called_once_with(ANY, "1.1.1.1")
mock_apiclient.__aenter__.assert_called_once()

View File

@@ -90,6 +90,7 @@ async def test_device_already_configured(
async def test_user_step_fail_with_error(
hass: HomeAssistant,
mock_lunatone_info: AsyncMock,
mock_setup_entry: AsyncMock,
exception: Exception,
expected_error: str,
) -> None:
@@ -124,6 +125,7 @@ async def test_user_step_fail_with_error(
async def test_reconfigure(
hass: HomeAssistant,
mock_lunatone_info: AsyncMock,
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test reconfigure flow."""
@@ -153,6 +155,7 @@ async def test_reconfigure(
async def test_reconfigure_fail_with_error(
hass: HomeAssistant,
mock_lunatone_info: AsyncMock,
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
exception: Exception,
expected_error: str,

View File

@@ -46,6 +46,6 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
'state': 'on',
})
# ---

View File

@@ -20,6 +20,7 @@ from tests.common import MockConfigEntry, snapshot_platform
async def test_binary_sensor_setup(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
mock_madvr_client: AsyncMock,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
) -> None:

View File

@@ -38,6 +38,7 @@ from tests.common import MockConfigEntry, snapshot_platform
async def test_remote_setup(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
mock_madvr_client: AsyncMock,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
) -> None:

View File

@@ -9,7 +9,9 @@ import pytest
@pytest.fixture
def mock_simple_manager_fail():
"""Mock datapoint Manager with default values for testing in config_flow."""
with patch("datapoint.Manager.Manager") as mock_manager:
with patch(
"homeassistant.components.metoffice.config_flow.Manager"
) as mock_manager:
instance = mock_manager.return_value
instance.get_forecast = APIException()
instance.latitude = None

View File

@@ -687,10 +687,11 @@ async def test_discovered_by_dhcp_updates_host(
assert config_entry.data[CONF_HOST] == "1.2.3.4"
await hass.config_entries.async_unload(config_entry.entry_id)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DHCP}, data=DHCP_DISCOVERY
)
await hass.async_block_till_done()
with patch("homeassistant.components.onvif.async_setup_entry", return_value=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DHCP}, data=DHCP_DISCOVERY
)
await hass.async_block_till_done()
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

View File

@@ -1,8 +1,10 @@
"""Test the Panasonic Viera config flow."""
from unittest.mock import patch
from collections.abc import Generator
from unittest.mock import AsyncMock, patch
from panasonic_viera import SOAPError
import pytest
from homeassistant import config_entries
from homeassistant.components.panasonic_viera.const import (
@@ -26,6 +28,16 @@ from .conftest import (
from tests.common import MockConfigEntry
@pytest.fixture(autouse=True)
def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.panasonic_viera.async_setup_entry",
return_value=True,
) as mock_setup:
yield mock_setup
async def test_flow_non_encrypted(hass: HomeAssistant) -> None:
"""Test flow without encryption."""

View File

@@ -122,9 +122,12 @@ async def test_unknown_error(hass: HomeAssistant) -> None:
async def test_zero_conf(hass: HomeAssistant) -> None:
"""Test the manual flow for zero config."""
with patch(
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
return_value=("v3", API_KEY, "/test"),
with (
patch(
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
return_value=("v3", API_KEY, "/test"),
),
patch_async_setup_entry(),
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -139,9 +142,12 @@ async def test_zero_conf(hass: HomeAssistant) -> None:
async def test_url_rewrite(hass: HomeAssistant) -> None:
"""Test auth flow url rewrite."""
with patch(
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
return_value=("v3", API_KEY, "/test"),
with (
patch(
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
return_value=("v3", API_KEY, "/test"),
),
patch_async_setup_entry(),
):
result = await hass.config_entries.flow.async_init(
DOMAIN,

View File

@@ -264,7 +264,9 @@ async def test_ssdp_discovery(
async def test_options_flow(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
hass: HomeAssistant,
mock_setup_entry: None,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test options config flow."""
mock_config_entry.add_to_hass(hass)

View File

@@ -31,7 +31,8 @@ async def test_setup_success_no_region(hass: HomeAssistant) -> None:
)
mock_config.add_to_hass(hass)
result = await async_setup_component(hass=hass, domain=DOMAIN, config={})
with patch("homeassistant.components.sharkiq.async_setup_entry", return_value=True):
result = await async_setup_component(hass=hass, domain=DOMAIN, config={})
assert result is True

View File

@@ -149,7 +149,9 @@ async def test_dhcp_discovery(
async def test_dhcp_already_configured(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_setup_entry: AsyncMock,
) -> None:
"""Test starting a flow by dhcp when already configured."""
mock_config_entry.add_to_hass(hass)
@@ -162,7 +164,9 @@ async def test_dhcp_already_configured(
async def test_dhcp_already_configured_duplicate(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_sma_client: MagicMock,
) -> None:
"""Test starting a flow by DHCP when already configured and MAC is added."""
mock_config_entry.add_to_hass(hass)
@@ -280,6 +284,7 @@ async def test_full_flow_reauth(
async def test_reauth_flow_exceptions(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_setup_entry: AsyncMock,
exception: Exception,
error: str,
) -> None:

View File

@@ -244,6 +244,55 @@
'state': 'on',
})
# ---
# name: test_all_entities[da_ks_hood_01001][switch.range_hood_do_not_disturb-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.range_hood_do_not_disturb',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Do not disturb',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Do not disturb',
'platform': 'smartthings',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'do_not_disturb',
'unique_id': 'fa5fca25-fa7a-1807-030a-2f72ee0f7bff_main_custom.doNotDisturbMode_doNotDisturb_doNotDisturb',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[da_ks_hood_01001][switch.range_hood_do_not_disturb-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Range hood Do not disturb',
}),
'context': <ANY>,
'entity_id': 'switch.range_hood_do_not_disturb',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[da_ks_walloven_0107x][switch.four_sabbath_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@@ -979,6 +1028,55 @@
'state': 'on',
})
# ---
# name: test_all_entities[da_rvc_map_01011][switch.robot_vacuum_do_not_disturb-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.robot_vacuum_do_not_disturb',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Do not disturb',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Do not disturb',
'platform': 'smartthings',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'do_not_disturb',
'unique_id': '05accb39-2017-c98b-a5ab-04a81f4d3d9a_main_custom.doNotDisturbMode_doNotDisturb_doNotDisturb',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[da_rvc_map_01011][switch.robot_vacuum_do_not_disturb-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Robot vacuum Do not disturb',
}),
'context': <ANY>,
'entity_id': 'switch.robot_vacuum_do_not_disturb',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[da_rvc_normal_000001][switch.robot_vacuum-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -7,6 +7,16 @@ import pytest
from . import MOCK_SERVERS
@pytest.fixture
def mock_setup_entry():
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.speedtestdotnet.async_setup_entry",
return_value=True,
) as mock_setup:
yield mock_setup
@pytest.fixture
def mock_api():
"""Mock entry setup."""

View File

@@ -14,7 +14,7 @@ from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
async def test_flow_works(hass: HomeAssistant) -> None:
async def test_flow_works(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
"""Test user config."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}

View File

@@ -25,12 +25,15 @@ async def test_flow_user(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
assert result["errors"] == {}
with patch_config_flow_tautulli(AsyncMock()):
with (
patch_config_flow_tautulli(AsyncMock()),
patch("homeassistant.components.tautulli.async_setup_entry", return_value=True),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DATA,
)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == NAME
@@ -48,12 +51,15 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
assert result["errors"]["base"] == "cannot_connect"
with patch_config_flow_tautulli(AsyncMock()):
with (
patch_config_flow_tautulli(AsyncMock()),
patch("homeassistant.components.tautulli.async_setup_entry", return_value=True),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DATA,
)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == NAME
@@ -71,12 +77,15 @@ async def test_flow_user_invalid_auth(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
assert result["errors"]["base"] == "invalid_auth"
with patch_config_flow_tautulli(AsyncMock()):
with (
patch_config_flow_tautulli(AsyncMock()),
patch("homeassistant.components.tautulli.async_setup_entry", return_value=True),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DATA,
)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == NAME
@@ -94,12 +103,15 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
assert result["errors"]["base"] == "unknown"
with patch_config_flow_tautulli(AsyncMock()):
with (
patch_config_flow_tautulli(AsyncMock()),
patch("homeassistant.components.tautulli.async_setup_entry", return_value=True),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DATA,
)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == NAME
@@ -138,12 +150,15 @@ async def test_flow_user_multiple_entries_allowed(hass: HomeAssistant) -> None:
CONF_API_KEY: "efgh",
CONF_VERIFY_SSL: True,
}
with patch_config_flow_tautulli(AsyncMock()):
with (
patch_config_flow_tautulli(AsyncMock()),
patch("homeassistant.components.tautulli.async_setup_entry", return_value=True),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=user_input,
)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == NAME

View File

@@ -57,6 +57,8 @@ async def test_service_reconnect_client(
async def test_service_reconnect_failed_with_invalid_entry(
hass: HomeAssistant,
mock_omada_site_client: MagicMock,
mock_omada_client: MagicMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test reconnect with invalid config entry raises ServiceValidationError."""
@@ -102,6 +104,8 @@ async def test_service_reconnect_without_config_entry_id(
async def test_service_reconnect_entry_not_loaded(
hass: HomeAssistant,
mock_omada_site_client: MagicMock,
mock_omada_client: MagicMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test reconnect service raises error when entry is not loaded."""

View File

@@ -30,6 +30,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
async def test_config_flow_entry_migrate_1_1_to_1_2(
hass: HomeAssistant,
mock_transmission_client: AsyncMock,
) -> None:
"""Test that config flow entry is migrated correctly from v1.1 to v1.2."""
entry = MockConfigEntry(
@@ -150,6 +151,7 @@ async def test_unload_entry(
)
async def test_migrate_unique_id(
hass: HomeAssistant,
mock_transmission_client: AsyncMock,
entity_registry: er.EntityRegistry,
domain: str,
old_unique_id: str,

View File

@@ -153,12 +153,9 @@ async def test_reboot_gateway_service_raises_on_exception(
async def test_reboot_gateway_service_raises_validation_error(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
hass: HomeAssistant,
) -> None:
"""Test that reboot_gateway service raises ServiceValidationError when no gateway is loaded."""
# Add the config entry but don't set it up
mock_config_entry.add_to_hass(hass)
# Set up the velux integration's async_setup to register the service
await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()

View File

@@ -159,9 +159,10 @@ async def test_full_ssdp_flow_implementation(hass: HomeAssistant) -> None:
"components": "light",
}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
with patch("homeassistant.components.wilight.async_setup_entry", return_value=True):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"WL{WILIGHT_ID}"