mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Replace unused mock_setup_entry arguments with @pytest.mark.usefixtures (#170760)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
a1e22c22d3
commit
5472a537ed
@@ -36,11 +36,9 @@ def mock_discovered_service_info() -> Generator[AsyncMock]:
|
||||
yield mock_discovered_service_info
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_verify: AsyncMock,
|
||||
mock_discovered_service_info: AsyncMock,
|
||||
hass: HomeAssistant, mock_verify: AsyncMock, mock_discovered_service_info: AsyncMock
|
||||
) -> None:
|
||||
"""Test we get the form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -65,11 +63,8 @@ async def test_form(
|
||||
}
|
||||
|
||||
|
||||
async def test_bluetooth_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_verify: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_bluetooth_discovery(hass: HomeAssistant, mock_verify: AsyncMock) -> None:
|
||||
"""Test we can discover a device."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -167,9 +162,9 @@ async def test_already_configured_bluetooth_discovery(
|
||||
(AcaiaError, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_recoverable_config_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_verify: AsyncMock,
|
||||
mock_discovered_service_info: AsyncMock,
|
||||
exception: Exception,
|
||||
@@ -203,11 +198,9 @@ async def test_recoverable_config_flow_errors(
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_unsupported_device(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_verify: AsyncMock,
|
||||
mock_discovered_service_info: AsyncMock,
|
||||
hass: HomeAssistant, mock_verify: AsyncMock, mock_discovered_service_info: AsyncMock
|
||||
) -> None:
|
||||
"""Test flow aborts on unsupported device."""
|
||||
mock_verify.side_effect = AcaiaUnknownDevice
|
||||
@@ -227,10 +220,9 @@ async def test_unsupported_device(
|
||||
assert result2["reason"] == "unsupported_device"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_no_bluetooth_devices(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_discovered_service_info: AsyncMock,
|
||||
hass: HomeAssistant, mock_discovered_service_info: AsyncMock
|
||||
) -> None:
|
||||
"""Test flow aborts on unsupported device."""
|
||||
mock_discovered_service_info.return_value = []
|
||||
|
||||
@@ -5,6 +5,7 @@ from unittest.mock import AsyncMock
|
||||
|
||||
from actron_neo_api import ActronAirAuthError
|
||||
from actron_neo_api.models.auth import ActronAirUserInfo
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.actron_air.const import DOMAIN
|
||||
@@ -15,8 +16,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_oauth2_success(
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock
|
||||
) -> None:
|
||||
"""Test successful OAuth2 device code flow."""
|
||||
# Start the config flow
|
||||
@@ -90,8 +92,9 @@ async def test_user_flow_oauth2_error(hass: HomeAssistant, mock_actron_api) -> N
|
||||
assert result["reason"] == "oauth2_error"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_token_polling_error(
|
||||
hass: HomeAssistant, mock_actron_api, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_actron_api
|
||||
) -> None:
|
||||
"""Test OAuth2 flow with error during token polling."""
|
||||
# Override the default mock to raise an error during token polling
|
||||
@@ -182,11 +185,9 @@ async def test_user_flow_duplicate_account(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_actron_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test successful reauthentication flow."""
|
||||
# Create an existing config entry
|
||||
@@ -260,8 +261,9 @@ async def test_reauth_flow_wrong_account(
|
||||
assert result["reason"] == "wrong_account"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_timeout(
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock
|
||||
) -> None:
|
||||
"""Test OAuth2 flow when login task raises a non-CannotConnect exception."""
|
||||
|
||||
@@ -316,8 +318,9 @@ async def test_user_flow_timeout(
|
||||
assert result["title"] == "test@example.com"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_finish_login_auth_error(
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock
|
||||
) -> None:
|
||||
"""Test finish_login step when get_user_info raises ActronAirAuthError."""
|
||||
# Start the config flow
|
||||
@@ -341,11 +344,9 @@ async def test_finish_login_auth_error(
|
||||
assert result["reason"] == "oauth2_error"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_actron_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_actron_api: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test successful reconfiguration flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from pyaftership import AfterShipException
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.aftership.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
@@ -11,7 +12,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
async def test_full_user_flow(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_user_flow(hass: HomeAssistant) -> None:
|
||||
"""Test the full user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -36,7 +38,8 @@ async def test_full_user_flow(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||
}
|
||||
|
||||
|
||||
async def test_flow_cannot_connect(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test handling invalid connection."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
||||
@@ -8,6 +8,7 @@ from airgradient import (
|
||||
AirGradientParseError,
|
||||
ConfigurationControl,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.airgradient.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
@@ -49,10 +50,9 @@ ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_new_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_new_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -79,10 +79,9 @@ async def test_full_flow(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_with_registered_device(
|
||||
hass: HomeAssistant,
|
||||
mock_cloud_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_cloud_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test we don't revert the cloud setting."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -101,10 +100,9 @@ async def test_flow_with_registered_device(
|
||||
mock_cloud_airgradient_client.set_configuration_control.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test flow errors."""
|
||||
mock_airgradient_client.get_current_measures.side_effect = (
|
||||
@@ -138,10 +136,9 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_old_firmware_version(
|
||||
hass: HomeAssistant,
|
||||
mock_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test flow with old firmware version."""
|
||||
mock_airgradient_client.get_current_measures.side_effect = AirGradientParseError
|
||||
@@ -164,10 +161,10 @@ async def test_flow_old_firmware_version(
|
||||
assert result["reason"] == "invalid_version"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
@@ -191,10 +188,9 @@ async def test_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_new_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_new_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -222,10 +218,9 @@ async def test_zeroconf_flow(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_flow_cloud_device(
|
||||
hass: HomeAssistant,
|
||||
mock_cloud_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_cloud_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf flow doesn't revert the cloud setting."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -269,10 +264,9 @@ async def test_zeroconf_flow_abort_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_works_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_new_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_new_airgradient_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test user flow can continue after discovery happened."""
|
||||
await hass.config_entries.flow.async_init(
|
||||
@@ -298,10 +292,10 @@ async def test_user_flow_works_discovery(
|
||||
assert not hass.config_entries.flow.async_progress(DOMAIN)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_new_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
@@ -324,10 +318,10 @@ async def test_reconfigure_flow(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_new_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
@@ -364,10 +358,10 @@ async def test_reconfigure_flow_errors(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_unique_id_mismatch(
|
||||
hass: HomeAssistant,
|
||||
mock_new_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow aborts with unique id mismatch."""
|
||||
|
||||
@@ -93,9 +93,9 @@ async def test_form_exceptions(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -116,10 +116,9 @@ async def test_duplicate_entry(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
hass: HomeAssistant, mock_airobot_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test DHCP discovery flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -204,9 +203,9 @@ async def test_dhcp_discovery_errors(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -235,9 +234,9 @@ async def test_dhcp_discovery_duplicate(
|
||||
assert mock_config_entry.data[CONF_HOST] == "192.168.1.101"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -271,9 +270,9 @@ async def test_reauth_flow(
|
||||
(Exception("Unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
@@ -310,9 +309,9 @@ async def test_reauth_flow_errors(
|
||||
assert mock_config_entry.data[CONF_PASSWORD] == "new-password"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -342,9 +341,9 @@ async def test_reconfigure_flow(
|
||||
assert mock_config_entry.data[CONF_PASSWORD] == "new-password"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_wrong_device(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -379,9 +378,9 @@ async def test_reconfigure_flow_wrong_device(
|
||||
(Exception("Unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_airobot_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
|
||||
@@ -208,12 +208,12 @@ async def test_form_exception_handling(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_scenario(
|
||||
hass: HomeAssistant,
|
||||
ap_status_fixture: AirOSData,
|
||||
mock_airos_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test successful reauthentication."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -574,11 +574,9 @@ async def test_discover_flow_no_devices_found(
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_discover_flow_one_device_found(
|
||||
hass: HomeAssistant,
|
||||
mock_airos_client: AsyncMock,
|
||||
mock_discovery_method: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_airos_client: AsyncMock, mock_discovery_method: AsyncMock
|
||||
) -> None:
|
||||
"""Test discovery flow goes straight to credentials when one device is found."""
|
||||
mock_discovery_method.return_value = {MOCK_DISC_DEV1[MAC_ADDRESS]: MOCK_DISC_DEV1}
|
||||
@@ -622,12 +620,12 @@ async def test_discover_flow_one_device_found(
|
||||
assert result["data"][CONF_HOST] == MOCK_DISC_DEV1[IP_ADDRESS]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_discover_flow_multiple_devices_found(
|
||||
hass: HomeAssistant,
|
||||
mock_airos_client: AsyncMock,
|
||||
mock_async_get_firmware_data: AsyncMock,
|
||||
mock_discovery_method: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test discovery flow with multiple devices found, requiring a selection step."""
|
||||
mock_discovery_method.return_value = {
|
||||
|
||||
@@ -69,10 +69,10 @@ async def test_full_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_airthings_token: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
|
||||
@@ -24,10 +24,9 @@ from .const import TEST_CODE, TEST_PASSWORD, TEST_USER_ID, TEST_USERNAME
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_amazon_devices_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -69,10 +68,10 @@ async def test_full_flow(
|
||||
(CannotRetrieveData, "cannot_retrieve_data"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
@@ -112,10 +111,10 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
@@ -142,10 +141,10 @@ async def test_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_successful(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test starting a reauthentication flow."""
|
||||
@@ -184,10 +183,10 @@ async def test_reauth_successful(
|
||||
(CannotRetrieveData, "cannot_retrieve_data"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_not_successful(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
side_effect: Exception,
|
||||
error: str,
|
||||
@@ -234,10 +233,10 @@ async def test_reauth_not_successful(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_successful(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that the entry can be reconfigured."""
|
||||
@@ -282,10 +281,10 @@ async def test_reconfigure_successful(
|
||||
(CannotRetrieveData, "cannot_retrieve_data"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_fails(
|
||||
hass: HomeAssistant,
|
||||
mock_amazon_devices_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
side_effect: Exception,
|
||||
error: str,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
from ipaddress import ip_address
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.altruist.const import CONF_HOST, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -24,10 +26,9 @@ ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_user_step_success(
|
||||
hass: HomeAssistant,
|
||||
mock_altruist_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_altruist_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test user step shows form and succeeds with valid input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -48,11 +49,11 @@ async def test_form_user_step_success(
|
||||
assert result["result"].unique_id == "5366960e8b18"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_user_step_cannot_connect_then_recovers(
|
||||
hass: HomeAssistant,
|
||||
mock_altruist_client: AsyncMock,
|
||||
mock_altruist_client_fails_once: None,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test we handle connection error and allow recovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -82,11 +83,11 @@ async def test_form_user_step_cannot_connect_then_recovers(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_user_step_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_altruist_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test we abort if already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -104,10 +105,9 @@ async def test_form_user_step_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_altruist_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_altruist_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf discovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -131,11 +131,11 @@ async def test_zeroconf_discovery(
|
||||
assert result["result"].unique_id == "5366960e8b18"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_discovery_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_altruist_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test zeroconf discovery when already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -150,11 +150,11 @@ async def test_zeroconf_discovery_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_discovery_cant_create_client(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_altruist_client_fails_once: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test zeroconf discovery when already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -161,9 +161,8 @@ async def test_form_cannot_connect(
|
||||
assert result["reason"] == reason
|
||||
|
||||
|
||||
async def test_form_already_configured(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
||||
@@ -21,9 +21,9 @@ from .const import ACCESS_TOKEN, ACCOUNT_NUMBER, PASSWORD, USERNAME
|
||||
from tests.common import MockConfigEntry, async_load_json_object_fixture
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_multiple_account_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_anglian_water_authenticator: AsyncMock,
|
||||
mock_anglian_water_client: AsyncMock,
|
||||
) -> None:
|
||||
@@ -62,9 +62,9 @@ async def test_multiple_account_flow(
|
||||
assert result["result"].unique_id == ACCOUNT_NUMBER
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_single_account_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_anglian_water_authenticator: AsyncMock,
|
||||
mock_anglian_water_client: AsyncMock,
|
||||
) -> None:
|
||||
@@ -99,9 +99,9 @@ async def test_single_account_flow(
|
||||
assert result["result"].unique_id == ACCOUNT_NUMBER
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_anglian_water_authenticator: AsyncMock,
|
||||
mock_anglian_water_client: AsyncMock,
|
||||
|
||||
@@ -35,9 +35,9 @@ async def test_config_flow_cannot_connect(
|
||||
assert result["errors"]["base"] == "cannot_connect"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_config_flow_duplicate_host_port(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_request_status: AsyncMock,
|
||||
) -> None:
|
||||
@@ -68,9 +68,9 @@ async def test_config_flow_duplicate_host_port(
|
||||
assert result["data"] == another_host
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_config_flow_duplicate_serial_number(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_request_status: AsyncMock,
|
||||
) -> None:
|
||||
@@ -191,9 +191,9 @@ async def test_reconfigure_flow_works(
|
||||
assert mock_config_entry.data[CONF_PORT] == new_conf_data[CONF_PORT]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_cannot_connect(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_request_status: AsyncMock,
|
||||
) -> None:
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.apsystems.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
||||
@@ -11,8 +13,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_create_success(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_apsystems: AsyncMock
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock
|
||||
) -> None:
|
||||
"""Test we handle creatinw with success."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -27,8 +30,9 @@ async def test_form_create_success(
|
||||
assert result["data"].get(CONF_IP_ADDRESS) == "127.0.0.1"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_create_success_custom_port(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_apsystems: AsyncMock
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock
|
||||
) -> None:
|
||||
"""Test we handle creating with custom port with success."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -45,8 +49,9 @@ async def test_form_create_success_custom_port(
|
||||
assert result["data"].get(CONF_PORT) == 8042
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_cannot_connect_and_recover(
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
|
||||
@@ -75,8 +80,9 @@ async def test_form_cannot_connect_and_recover(
|
||||
assert result2["data"].get(CONF_IP_ADDRESS) == "127.0.0.1"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_cannot_connect_and_recover_custom_port(
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error but recovering with custom port."""
|
||||
|
||||
@@ -102,11 +108,9 @@ async def test_form_cannot_connect_and_recover_custom_port(
|
||||
assert result2["data"].get(CONF_PORT) == 8042
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_unique_id_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_apsystems: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_apsystems: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.arve.config_flow import ArveConnectionError
|
||||
from homeassistant.components.arve.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
@@ -37,9 +39,8 @@ async def test_correct_flow(
|
||||
assert result2["result"].unique_id == "12345"
|
||||
|
||||
|
||||
async def test_form_cannot_connect(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_arve: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_cannot_connect(hass: HomeAssistant, mock_arve: AsyncMock) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
mock_arve.get_customer_id.side_effect = ArveConnectionError
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -48,9 +48,9 @@ async def test_full_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_aurora_client: AsyncMock,
|
||||
side_effect: Exception,
|
||||
error: str,
|
||||
@@ -77,9 +77,9 @@ async def test_form_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_option_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_aurora_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
|
||||
@@ -73,10 +73,10 @@ async def test_duplicate_entry(
|
||||
(AutarcoAuthenticationError, "invalid_auth"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_autarco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
@@ -102,10 +102,9 @@ async def test_exceptions(
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_reauth(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauth flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -134,11 +133,11 @@ async def test_step_reauth(
|
||||
(AutarcoAuthenticationError, "invalid_auth"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_reauth_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_autarco_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
|
||||
@@ -26,11 +26,8 @@ USER_INPUT = {
|
||||
}
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_autoskope_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_autoskope_client: AsyncMock) -> None:
|
||||
"""Test full user config flow from form to entry creation."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -60,10 +57,10 @@ async def test_full_flow(
|
||||
(CannotConnect("Connection failed"), "cannot_connect"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_autoskope_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
@@ -91,10 +88,9 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_invalid_url(
|
||||
hass: HomeAssistant,
|
||||
mock_autoskope_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_autoskope_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test config flow rejects invalid URL with recovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -142,10 +138,9 @@ async def test_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_custom_host(
|
||||
hass: HomeAssistant,
|
||||
mock_autoskope_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_autoskope_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test config flow with a custom white-label host."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -167,11 +162,11 @@ async def test_custom_host(
|
||||
assert result["result"].unique_id == "test_user@https://custom.autoskope.server"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_autoskope_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test reauth flow updates password and reloads entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -201,11 +196,11 @@ async def test_reauth_flow(
|
||||
(CannotConnect("Connection failed"), "cannot_connect"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_autoskope_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Test the Azure storage config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from azure.core.exceptions import ClientAuthenticationError, ResourceNotFoundError
|
||||
import pytest
|
||||
@@ -38,11 +38,8 @@ async def __async_start_flow(
|
||||
)
|
||||
|
||||
|
||||
async def test_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow(hass: HomeAssistant, mock_client: MagicMock) -> None:
|
||||
"""Test config flow."""
|
||||
mock_client.exists.return_value = False
|
||||
result = await __async_start_flow(hass)
|
||||
@@ -67,10 +64,10 @@ async def test_flow(
|
||||
(Exception, {"base": "unknown"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
errors: dict[str, str],
|
||||
) -> None:
|
||||
@@ -114,10 +111,9 @@ async def test_abort_if_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that the reauth flow works."""
|
||||
|
||||
@@ -139,11 +135,9 @@ async def test_reauth_flow(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_client: MagicMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that the reauth flow works with an errors."""
|
||||
|
||||
@@ -174,10 +168,9 @@ async def test_reauth_flow_errors(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that the reconfigure flow works."""
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ async def test_form_user(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_panel: AsyncMock,
|
||||
config_flow_data: dict[str, Any],
|
||||
exception: Exception,
|
||||
@@ -116,9 +116,9 @@ async def test_form_exceptions(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_exceptions_user(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_panel: AsyncMock,
|
||||
config_flow_data: dict[str, Any],
|
||||
exception: Exception,
|
||||
@@ -208,9 +208,9 @@ async def test_entry_already_configured_serial(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_can_finish(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
serial_number: str,
|
||||
@@ -255,9 +255,9 @@ async def test_dhcp_can_finish(
|
||||
(Exception(), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
serial_number: str,
|
||||
@@ -282,9 +282,9 @@ async def test_dhcp_exceptions(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mac_address", ["34ea34b43b5a"])
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_updates_host(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
mac_address: str | None,
|
||||
@@ -311,9 +311,9 @@ async def test_dhcp_updates_host(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("serial_number", ["12345678"])
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_if_panel_setup_config_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
serial_number: str,
|
||||
@@ -391,9 +391,9 @@ async def test_dhcp_abort_ongoing_flow(
|
||||
assert result["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_updates_mac(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
@@ -420,9 +420,9 @@ async def test_dhcp_updates_mac(
|
||||
assert mock_config_entry.data[CONF_MAC] == "34:ea:34:b4:3b:5a"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
@@ -455,9 +455,9 @@ async def test_reauth_flow_success(
|
||||
(Exception(), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_error(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
@@ -490,9 +490,9 @@ async def test_reauth_flow_error(
|
||||
assert compare == mock_config_entry.data
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfig_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
@@ -536,9 +536,9 @@ async def test_reconfig_flow(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["b5512"])
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfig_flow_incorrect_model(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_panel: AsyncMock,
|
||||
panel_model: PanelModel,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from unittest.mock import DEFAULT, AsyncMock, patch
|
||||
|
||||
from evolutionhttp import BryantEvolutionLocalClient, ZoneInfo
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.bryant_evolution.const import CONF_SYSTEM_ZONE, DOMAIN
|
||||
@@ -104,10 +105,9 @@ async def test_form_cannot_connect(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_cannot_connect_bad_file(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_evolution_client_factory: AsyncMock,
|
||||
hass: HomeAssistant, mock_evolution_client_factory: AsyncMock
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error from a missing file."""
|
||||
mock_evolution_client_factory.side_effect = FileNotFoundError("test error")
|
||||
@@ -126,10 +126,9 @@ async def test_form_cannot_connect_bad_file(
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_evolution_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_evolution_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that reconfigure discovers additional systems and zones."""
|
||||
|
||||
|
||||
@@ -174,11 +174,9 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
|
||||
"side_effect",
|
||||
[BSBLANError, TimeoutError],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_circuit_discovery_failure_falls_back_to_default(
|
||||
hass: HomeAssistant,
|
||||
mock_bsblan: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: type[Exception],
|
||||
hass: HomeAssistant, mock_bsblan: MagicMock, side_effect: type[Exception]
|
||||
) -> None:
|
||||
"""Test that circuit discovery failure falls back to single circuit."""
|
||||
mock_bsblan.initialize.side_effect = side_effect
|
||||
@@ -213,10 +211,9 @@ async def test_circuit_discovery_failure_falls_back_to_default(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_circuit_discovery_empty_result_falls_back_to_default(
|
||||
hass: HomeAssistant,
|
||||
mock_bsblan: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_bsblan: MagicMock
|
||||
) -> None:
|
||||
"""Test that empty circuit discovery falls back to single circuit."""
|
||||
mock_bsblan.get_available_circuits.return_value = []
|
||||
|
||||
@@ -246,11 +246,9 @@ async def test_multiple_config_entries(
|
||||
},
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_config_entries(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
config_entry: MockConfigEntry,
|
||||
user_input: dict[str, str],
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, user_input: dict[str, str]
|
||||
) -> None:
|
||||
"""Test multiple configuration entries with the same settings."""
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from ipaddress import ip_address
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from aiostreammagic import StreamMagicError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.cambridge_audio.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF, ConfigFlowResult
|
||||
@@ -31,10 +32,9 @@ ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_stream_magic_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -56,10 +56,9 @@ async def test_full_flow(
|
||||
assert result["result"].unique_id == "0020c2d8"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_stream_magic_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test flow errors."""
|
||||
mock_stream_magic_client.connect.side_effect = StreamMagicError
|
||||
@@ -88,10 +87,10 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
@@ -113,10 +112,9 @@ async def test_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_stream_magic_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -139,10 +137,9 @@ async def test_zeroconf_flow(
|
||||
assert result["result"].unique_id == "0020c2d8"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_stream_magic_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf flow."""
|
||||
mock_stream_magic_client.connect.side_effect = StreamMagicError
|
||||
@@ -176,10 +173,10 @@ async def test_zeroconf_flow_errors(
|
||||
assert result["result"].unique_id == "0020c2d8"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
@@ -211,10 +208,10 @@ async def _start_reconfigure_flow(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
@@ -231,10 +228,10 @@ async def test_reconfigure_flow(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_unique_id_mismatch(
|
||||
hass: HomeAssistant,
|
||||
mock_stream_magic_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Ensure reconfigure flow aborts when the bride changes."""
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.ccm15.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
@@ -79,9 +81,8 @@ async def test_form_invalid_host(
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_form_cannot_connect(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -113,9 +114,8 @@ async def test_form_cannot_connect(
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_form_unexpected_error(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_unexpected_error(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -148,7 +148,8 @@ async def test_form_unexpected_error(
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_duplicate_host(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_host(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
||||
@@ -14,8 +14,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_dio_chacon_client: AsyncMock
|
||||
hass: HomeAssistant, mock_dio_chacon_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test the full flow."""
|
||||
|
||||
@@ -52,9 +53,9 @@ async def test_full_flow(
|
||||
(DIOChaconAPIError, {"base": "cannot_connect"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_dio_chacon_client: AsyncMock,
|
||||
exception: Exception,
|
||||
expected: dict[str, str],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for the Leviton Decora Wi-Fi config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -14,10 +14,9 @@ from .const import TEST_USER_ID, TEST_USERNAME, USER_INPUT
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_decora_wifi: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_decora_wifi: MagicMock
|
||||
) -> None:
|
||||
"""Test a successful user-initiated config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -43,10 +42,10 @@ async def test_user_flow_success(
|
||||
(True, ValueError("Cannot connect"), "cannot_connect"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_error_and_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_decora_wifi: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
login_return_value: bool | None,
|
||||
login_side_effect: Exception | None,
|
||||
expected_error: str,
|
||||
@@ -93,10 +92,9 @@ async def test_user_flow_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_decora_wifi: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_decora_wifi: MagicMock
|
||||
) -> None:
|
||||
"""Test a successful YAML import flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -153,7 +153,6 @@ async def test_flow_reconfigure(
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_reconfigure_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_update_duckdns: AsyncMock,
|
||||
config_entry: MockConfigEntry,
|
||||
side_effect: list[Exception | bool],
|
||||
|
||||
@@ -35,10 +35,9 @@ DHCP_DISCOVERY = DhcpServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_duco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_duco_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test a successful user flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -65,10 +64,10 @@ async def test_user_flow_success(
|
||||
(DucoError("Unexpected error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_error(
|
||||
hass: HomeAssistant,
|
||||
mock_duco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -114,10 +113,9 @@ async def test_user_flow_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_discovery_new_device(
|
||||
hass: HomeAssistant,
|
||||
mock_duco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_duco_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf discovery of a new device shows confirmation form and creates entry."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -319,10 +317,9 @@ async def test_reconfigure_flow_error(
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_new_device(
|
||||
hass: HomeAssistant,
|
||||
mock_duco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_duco_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test DHCP discovery of a new device shows confirmation form and creates entry."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -415,10 +412,9 @@ async def test_dhcp_discovery_exceptions(
|
||||
assert result["reason"] == expected_reason
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_exception_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_duco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_duco_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test DHCP discovery recovers after an initial exception and creates the entry."""
|
||||
mock_duco_client.async_get_board_info.side_effect = DucoConnectionError(
|
||||
@@ -453,11 +449,9 @@ async def test_dhcp_discovery_exception_recovery(
|
||||
assert result["result"].unique_id == TEST_MAC
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_initializes_client_with_host(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_board_info: BoardInfo,
|
||||
mock_lan_info: LanInfo,
|
||||
hass: HomeAssistant, mock_board_info: BoardInfo, mock_lan_info: LanInfo
|
||||
) -> None:
|
||||
"""Test that the config flow initializes the Duco client with the host."""
|
||||
with patch(
|
||||
|
||||
@@ -94,7 +94,7 @@ async def test_invalid(
|
||||
}
|
||||
|
||||
|
||||
async def test_already_setup(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
async def test_already_setup(hass: HomeAssistant) -> None:
|
||||
"""Test duoteco flow - already setup."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
||||
@@ -26,9 +26,8 @@ def _mock_device(
|
||||
return EarnEP1Device(host=host, serial=serial)
|
||||
|
||||
|
||||
async def test_user_flow_discovery_succeeds(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_discovery_succeeds(hass: HomeAssistant) -> None:
|
||||
"""Test user flow when auto-discovery finds a device with serial."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device()]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -47,9 +46,8 @@ async def test_user_flow_discovery_succeeds(
|
||||
assert result["result"].unique_id == MOCK_SERIAL
|
||||
|
||||
|
||||
async def test_user_flow_discovery_no_serial_validates(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_discovery_no_serial_validates(hass: HomeAssistant) -> None:
|
||||
"""Test discovery without serial triggers validation on confirm."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device(serial=None)]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -68,8 +66,9 @@ async def test_user_flow_discovery_no_serial_validates(
|
||||
assert result["data"][CONF_SERIAL] == MOCK_SERIAL
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_discovery_no_serial_validate_fails(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test discovery without serial aborts when validation also fails."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device(serial=None)]):
|
||||
@@ -86,9 +85,8 @@ async def test_user_flow_discovery_no_serial_validate_fails(
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_user_flow_discovery_no_serial_oserror(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_discovery_no_serial_oserror(hass: HomeAssistant) -> None:
|
||||
"""Test discovery without serial aborts on OSError during validation."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device(serial=None)]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -104,8 +102,9 @@ async def test_user_flow_discovery_no_serial_oserror(
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_discovery_no_serial_unexpected_error(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test discovery without serial aborts on unexpected error during validation."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device(serial=None)]):
|
||||
@@ -122,8 +121,9 @@ async def test_user_flow_discovery_no_serial_unexpected_error(
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_discovery_timeout_shows_manual_form(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test user flow falls back to manual form when discovery times out, then recovers."""
|
||||
with patch(DISCOVER_PATH, return_value=[]):
|
||||
@@ -144,9 +144,8 @@ async def test_user_flow_discovery_timeout_shows_manual_form(
|
||||
assert result["data"] == {CONF_HOST: MOCK_HOST, CONF_SERIAL: MOCK_SERIAL}
|
||||
|
||||
|
||||
async def test_manual_entry_validation_timeout_then_retry(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_manual_entry_validation_timeout_then_retry(hass: HomeAssistant) -> None:
|
||||
"""Test manual entry: validation timeout shows error, retry succeeds."""
|
||||
with patch(DISCOVER_PATH, return_value=[]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -176,11 +175,9 @@ async def test_manual_entry_validation_timeout_then_retry(
|
||||
(RuntimeError("boom"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_manual_entry_validation_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, side_effect: Exception, error: str
|
||||
) -> None:
|
||||
"""Test manual entry: errors during validation show correct error, retry succeeds."""
|
||||
with patch(DISCOVER_PATH, return_value=[]):
|
||||
@@ -204,10 +201,9 @@ async def test_manual_entry_validation_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_manual_entry_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test manual entry aborts when device is already configured."""
|
||||
with patch(DISCOVER_PATH, return_value=[]):
|
||||
@@ -224,10 +220,9 @@ async def test_manual_entry_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_discovery_confirm_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test discovery confirm aborts when device is already configured."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device()]):
|
||||
@@ -268,9 +263,8 @@ async def test_discover_uses_shared_listener(
|
||||
mock_listener.discover.assert_called_once()
|
||||
|
||||
|
||||
async def test_discover_without_shared_listener(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_discover_without_shared_listener(hass: HomeAssistant) -> None:
|
||||
"""Test _async_discover uses library discover when no shared listener."""
|
||||
with patch(DISCOVER_PATH, return_value=[_mock_device()]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -281,9 +275,8 @@ async def test_discover_without_shared_listener(
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
|
||||
async def test_discover_without_shared_listener_oserror(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_discover_without_shared_listener_oserror(hass: HomeAssistant) -> None:
|
||||
"""Test _async_discover falls back to manual form on OSError, then succeeds."""
|
||||
with patch(DISCOVER_PATH, side_effect=OSError("Address in use")):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -331,9 +324,8 @@ async def test_validate_uses_shared_listener(
|
||||
mock_listener.validate.assert_called_once()
|
||||
|
||||
|
||||
async def test_validate_without_shared_listener(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_validate_without_shared_listener(hass: HomeAssistant) -> None:
|
||||
"""Test _async_validate_host uses library validate when no shared listener."""
|
||||
with patch(DISCOVER_PATH, return_value=[]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -47,7 +47,7 @@ async def test_form(
|
||||
|
||||
|
||||
async def test_form_device_already_configured(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, config_entry, mock_device, config
|
||||
hass: HomeAssistant, config_entry, mock_device, config
|
||||
) -> None:
|
||||
"""Test device already exists."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -247,11 +247,9 @@ async def test_options_flow_init(
|
||||
mock_setup_entry.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_options_flow_voice_settings_default(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_async_client: AsyncMock,
|
||||
mock_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_async_client: AsyncMock, mock_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test options flow voice settings."""
|
||||
mock_entry.add_to_hass(hass)
|
||||
|
||||
@@ -114,8 +114,9 @@ async def test_user_flow_failure(
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_manual_mode(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, emoncms_client: AsyncMock
|
||||
hass: HomeAssistant, emoncms_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test we get the user forms and the entry in manual mode."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -202,9 +203,9 @@ async def test_options_flow_failure(
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_unique_id_exists(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
emoncms_client: AsyncMock,
|
||||
config_entry_unique_id: MockConfigEntry,
|
||||
) -> None:
|
||||
|
||||
@@ -27,11 +27,8 @@ from tests.common import MockConfigEntry
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def test_form(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form(hass: HomeAssistant, mock_envoy: AsyncMock) -> None:
|
||||
"""Test we get the form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -58,10 +55,9 @@ async def test_form(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_no_serial_number(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test user setup without a serial number."""
|
||||
mock_envoy.serial_number = None
|
||||
@@ -99,12 +95,9 @@ async def test_user_no_serial_number(
|
||||
(ValueError, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_envoy: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test we handle form errors."""
|
||||
mock_envoy.setup.side_effect = exception
|
||||
@@ -152,12 +145,9 @@ def _get_schema_default(schema, key_name):
|
||||
("3.0.0", "installer"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
version: str,
|
||||
schema_username: str,
|
||||
hass: HomeAssistant, mock_envoy: AsyncMock, version: str, schema_username: str
|
||||
) -> None:
|
||||
"""Test we can setup from zeroconf."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -199,11 +189,9 @@ async def test_zeroconf(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_host_already_exists(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test changing credentials for existing host."""
|
||||
config_entry.add_to_hass(hass)
|
||||
@@ -260,10 +248,10 @@ async def test_form_host_already_exists(
|
||||
assert config_entry.data[CONF_PASSWORD] == "changed-password"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_serial_already_exists(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
@@ -290,11 +278,9 @@ async def test_zeroconf_serial_already_exists(
|
||||
assert "Zeroconf ip 4 processing 4.4.4.4, current hosts: {'1.1.1.1'}" in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_serial_already_exists_ignores_ipv6(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test serial number already exists from zeroconf but the discovery is ipv6."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -318,11 +304,9 @@ async def test_zeroconf_serial_already_exists_ignores_ipv6(
|
||||
assert config_entry.data[CONF_HOST] == "1.1.1.1"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_host_already_exists(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test hosts already exists from zeroconf."""
|
||||
mock_envoy.serial_number = None
|
||||
@@ -347,11 +331,9 @@ async def test_zeroconf_host_already_exists(
|
||||
assert config_entry.title == "Envoy 1234"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zero_conf_while_form(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf while form is active."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -380,11 +362,9 @@ async def test_zero_conf_while_form(
|
||||
assert config_entry.title == "Envoy 1234"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zero_conf_second_envoy_while_form(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf while form is active."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -434,10 +414,9 @@ async def test_zero_conf_second_envoy_while_form(
|
||||
assert result4["type"] is FlowResultType.ABORT
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zero_conf_old_blank_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test reusing old blank entry."""
|
||||
entry = MockConfigEntry(
|
||||
@@ -473,10 +452,9 @@ async def test_zero_conf_old_blank_entry(
|
||||
assert entry.title == "Envoy 1234"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zero_conf_old_blank_entry_standard_title(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test reusing old blank entry was Envoy as title."""
|
||||
entry = MockConfigEntry(
|
||||
@@ -514,10 +492,9 @@ async def test_zero_conf_old_blank_entry_standard_title(
|
||||
assert entry.title == "Envoy 1234"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zero_conf_old_blank_entry_user_title(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test reusing old blank entry with user title."""
|
||||
entry = MockConfigEntry(
|
||||
@@ -555,11 +532,9 @@ async def test_zero_conf_old_blank_entry_user_title(
|
||||
assert entry.title == "Envoy Backyard"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test we reauth auth."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -577,11 +552,9 @@ async def test_reauth(
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_options_default(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test we can configure options."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -599,11 +572,9 @@ async def test_options_default(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_options_set(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test we can configure options."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -625,11 +596,9 @@ async def test_options_set(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test we can reconfiger the entry."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -661,11 +630,9 @@ async def test_reconfigure(
|
||||
assert config_entry.data[CONF_PASSWORD] == "test-password2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_nochange(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test we get the reconfigure form and apply nochange."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -697,11 +664,9 @@ async def test_reconfigure_nochange(
|
||||
assert config_entry.data[CONF_PASSWORD] == "test-password"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_otherenvoy(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test entering ip of other envoy and prevent changing it based on serial."""
|
||||
await setup_integration(hass, config_entry)
|
||||
@@ -739,10 +704,10 @@ async def test_reconfigure_otherenvoy(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_auth_failure(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -792,11 +757,9 @@ async def test_reconfigure_auth_failure(
|
||||
assert config_entry.data[CONF_PASSWORD] == "changed-password"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_change_ip_to_existing(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_envoy: AsyncMock,
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_envoy: AsyncMock
|
||||
) -> None:
|
||||
"""Test reconfiguration to existing entry with same ip does not harm existing one."""
|
||||
await setup_integration(hass, config_entry)
|
||||
|
||||
@@ -63,12 +63,9 @@ async def test_already_configured(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_essent_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_essent_client: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test flow errors."""
|
||||
mock_essent_client.async_get_prices.side_effect = exception
|
||||
|
||||
@@ -190,9 +190,8 @@ async def test_bluetooth_flow_errors(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_bluetooth_flow_no_device(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_bluetooth_flow_no_device(hass: HomeAssistant) -> None:
|
||||
"""Test we can handle a bluetooth discovery flow."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -441,10 +441,10 @@ async def test_user_custom_url_unknown_exception(
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_ezviz_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the flow when the account is already configured."""
|
||||
@@ -459,11 +459,11 @@ async def test_already_configured(
|
||||
assert result["reason"] == "already_configured_account"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_async_step_integration_discovery_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_ezviz_client: AsyncMock,
|
||||
mock_test_rtsp_auth: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_camera_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
|
||||
@@ -77,7 +77,6 @@ async def test_form(
|
||||
)
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_is_allowed_path: bool,
|
||||
platform: str,
|
||||
data: dict[str, Any],
|
||||
@@ -124,7 +123,6 @@ async def test_already_configured(
|
||||
)
|
||||
async def test_not_allowed(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_is_allowed_path: bool,
|
||||
platform: str,
|
||||
data: dict[str, Any],
|
||||
|
||||
@@ -32,10 +32,9 @@ USER_INPUT_RECONFIGURE = {
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_and_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_firefly_client: MagicMock,
|
||||
mock_setup_entry: MagicMock,
|
||||
hass: HomeAssistant, mock_firefly_client: MagicMock
|
||||
) -> None:
|
||||
"""Test we get the form and can complete the flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -75,10 +74,10 @@ async def test_form_and_flow(
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_firefly_client: AsyncMock,
|
||||
mock_setup_entry: MagicMock,
|
||||
exception: Exception,
|
||||
reason: str,
|
||||
) -> None:
|
||||
@@ -259,10 +258,10 @@ async def test_full_flow_reconfigure(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow_reconfigure_unique_id(
|
||||
hass: HomeAssistant,
|
||||
mock_firefly_client: AsyncMock,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the full flow of the config flow, this time with a known unique ID."""
|
||||
|
||||
@@ -25,10 +25,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_happy_path(
|
||||
hass: HomeAssistant,
|
||||
mock_fishaudio_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_fishaudio_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test the full user flow happy path."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -12,9 +12,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_flipr_client: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_flipr_client: AsyncMock) -> None:
|
||||
"""Test the full flow."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -51,9 +50,9 @@ async def test_full_flow(
|
||||
(ConnectionError, {"base": "cannot_connect"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_flipr_client: AsyncMock,
|
||||
exception: Exception,
|
||||
expected: dict[str, str],
|
||||
@@ -92,8 +91,9 @@ async def test_errors(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_no_flipr_found(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_flipr_client: AsyncMock
|
||||
hass: HomeAssistant, mock_flipr_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test the case where there is no flipr found."""
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant, mock_api_client: AsyncMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_api_client: AsyncMock) -> None:
|
||||
"""Test full config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -46,10 +45,10 @@ async def test_full_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_user_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -83,11 +82,9 @@ async def test_step_user_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_api_client: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test error cases for user step with recovery."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -37,9 +37,8 @@ async def _initial_step(hass: HomeAssistant) -> FlowResult:
|
||||
)
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_ayla_api: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_ayla_api: AsyncMock) -> None:
|
||||
"""Test full config flow."""
|
||||
result = await _initial_step(hass)
|
||||
mock_ayla_api.async_sign_in.assert_called_once()
|
||||
@@ -53,11 +52,9 @@ async def test_full_flow(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ayla_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_ayla_api: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that re-adding the same account fails."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -76,12 +73,9 @@ async def test_duplicate_entry(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ayla_api: AsyncMock,
|
||||
exception: Exception,
|
||||
err_msg: str,
|
||||
hass: HomeAssistant, mock_ayla_api: AsyncMock, exception: Exception, err_msg: str
|
||||
) -> None:
|
||||
"""Test we handle exceptions."""
|
||||
|
||||
@@ -111,11 +105,9 @@ async def test_form_exceptions(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_success(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ayla_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_ayla_api: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauth flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -144,11 +136,11 @@ async def test_reauth_success(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_exceptions(
|
||||
hass: HomeAssistant,
|
||||
exception: Exception,
|
||||
err_msg: str,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ayla_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
|
||||
@@ -165,10 +165,9 @@ async def test_duplicate_updates_existing_entry(
|
||||
assert len(mock_fully_kiosk_config_flow.getDeviceInfo.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_updates_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test DHCP discovery updates config entries."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -264,10 +263,10 @@ async def test_mqtt_discovery_flow(
|
||||
assert len(mock_fully_kiosk_config_flow.getDeviceInfo.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure(
|
||||
hass: HomeAssistant,
|
||||
mock_fully_kiosk_config_flow: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the reconfigure flow."""
|
||||
|
||||
@@ -145,12 +145,12 @@ async def test_duplicate_entry(
|
||||
(Exception, {"base": "unknown"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth(
|
||||
hass: HomeAssistant,
|
||||
exception: Exception,
|
||||
error: dict[str, str],
|
||||
mock_fyta_connector: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test reauth-flow works."""
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Test The generic (IP Camera) config flow."""
|
||||
|
||||
from collections.abc import Generator
|
||||
import contextlib
|
||||
from copy import deepcopy
|
||||
import errno
|
||||
@@ -65,14 +64,13 @@ TESTDATA_ONLYSTREAM.pop(CONF_STILL_IMAGE_URL)
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("fakeimg_png")
|
||||
@pytest.mark.usefixtures("fakeimg_png", "mock_setup_entry")
|
||||
async def test_form(
|
||||
hass: HomeAssistant,
|
||||
fakeimgbytes_png: bytes,
|
||||
hass_client: ClientSessionGenerator,
|
||||
user_flow: ConfigFlowResult,
|
||||
mock_create_stream: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
) -> None:
|
||||
"""Test the form with a normal set of settings."""
|
||||
@@ -131,11 +129,9 @@ async def test_form(
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("fakeimg_png")
|
||||
@pytest.mark.usefixtures("fakeimg_png", "mock_setup_entry")
|
||||
async def test_form_only_stillimage(
|
||||
hass: HomeAssistant,
|
||||
user_flow: ConfigFlowResult,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, user_flow: ConfigFlowResult
|
||||
) -> None:
|
||||
"""Test we complete ok if the user wants still images only."""
|
||||
result1 = await hass.config_entries.flow.async_configure(
|
||||
@@ -231,11 +227,9 @@ async def test_form_still_preview_cam_off(
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("fakeimg_gif")
|
||||
@pytest.mark.usefixtures("fakeimg_gif", "mock_setup_entry")
|
||||
async def test_form_only_stillimage_gif(
|
||||
hass: HomeAssistant,
|
||||
user_flow: ConfigFlowResult,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, user_flow: ConfigFlowResult
|
||||
) -> None:
|
||||
"""Test we complete ok if the user wants a gif."""
|
||||
result1 = await hass.config_entries.flow.async_configure(
|
||||
@@ -254,11 +248,9 @@ async def test_form_only_stillimage_gif(
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_only_svg_whitespace(
|
||||
hass: HomeAssistant,
|
||||
fakeimgbytes_svg: bytes,
|
||||
user_flow: ConfigFlowResult,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, fakeimgbytes_svg: bytes, user_flow: ConfigFlowResult
|
||||
) -> None:
|
||||
"""Test we complete ok if svg starts with whitespace, issue #68889."""
|
||||
fakeimgbytes_wspace_svg = bytes(" \n ", encoding="utf-8") + fakeimgbytes_svg
|
||||
@@ -288,8 +280,9 @@ async def test_form_only_svg_whitespace(
|
||||
("sample5_webp.webp"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_only_still_sample(
|
||||
hass: HomeAssistant, user_flow: ConfigFlowResult, image_file, mock_setup_entry
|
||||
hass: HomeAssistant, user_flow: ConfigFlowResult, image_file
|
||||
) -> None:
|
||||
"""Test various sample images #69037."""
|
||||
image_path = os.path.join(os.path.dirname(__file__), image_file)
|
||||
@@ -346,11 +339,11 @@ async def test_form_only_still_sample(
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_still_template(
|
||||
hass: HomeAssistant,
|
||||
user_flow: ConfigFlowResult,
|
||||
fakeimgbytes_png: bytes,
|
||||
mock_setup_entry: Generator[AsyncMock],
|
||||
template,
|
||||
url,
|
||||
expected_result,
|
||||
@@ -373,12 +366,9 @@ async def test_form_still_template(
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("fakeimg_png")
|
||||
@pytest.mark.usefixtures("fakeimg_png", "mock_setup_entry")
|
||||
async def test_form_rtsp_mode(
|
||||
hass: HomeAssistant,
|
||||
user_flow: ConfigFlowResult,
|
||||
mock_create_stream: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, user_flow: ConfigFlowResult, mock_create_stream: MagicMock
|
||||
) -> None:
|
||||
"""Test we complete ok if the user enters a stream url."""
|
||||
data = deepcopy(TESTDATA)
|
||||
@@ -809,11 +799,9 @@ async def test_slug(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> No
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("fakeimg_png")
|
||||
@pytest.mark.usefixtures("fakeimg_png", "mock_setup_entry")
|
||||
async def test_options_only_stream(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_create_stream: MagicMock,
|
||||
hass: HomeAssistant, mock_create_stream: MagicMock
|
||||
) -> None:
|
||||
"""Test the options flow without a still_image_url."""
|
||||
|
||||
@@ -845,10 +833,8 @@ async def test_options_only_stream(
|
||||
assert result3["data"][CONF_CONTENT_TYPE] == "image/jpeg"
|
||||
|
||||
|
||||
async def test_options_still_and_stream_not_provided(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_options_still_and_stream_not_provided(hass: HomeAssistant) -> None:
|
||||
"""Test we show a suitable error if neither still or stream URL are provided."""
|
||||
data = TESTDATA_ONLYSTILL.copy()
|
||||
data.pop(CONF_STILL_IMAGE_URL)
|
||||
@@ -937,7 +923,7 @@ async def test_migrate_existing_ids(
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("fakeimg_png")
|
||||
@pytest.mark.usefixtures("fakeimg_png", "mock_setup_entry")
|
||||
async def test_options_use_wallclock_as_timestamps(
|
||||
hass: HomeAssistant,
|
||||
mock_create_stream: MagicMock,
|
||||
@@ -945,7 +931,6 @@ async def test_options_use_wallclock_as_timestamps(
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
fakeimgbytes_png: bytes,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test the use_wallclock_as_timestamps option flow."""
|
||||
|
||||
|
||||
@@ -16,10 +16,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_local_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_geniushub_client: AsyncMock,
|
||||
hass: HomeAssistant, mock_geniushub_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full local flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -70,9 +69,9 @@ async def test_full_local_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_local_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_geniushub_client: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -182,10 +181,9 @@ async def test_local_duplicate_mac(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_cloud_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_geniushub_client: AsyncMock,
|
||||
hass: HomeAssistant, mock_geniushub_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full cloud flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -231,9 +229,9 @@ async def test_full_cloud_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_cloud_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_geniushub_client: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
|
||||
@@ -24,9 +24,8 @@ from tests.common import MockConfigEntry
|
||||
from tests.conftest import AiohttpClientMocker
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant, mock_srp_auth: AsyncMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_srp_auth: AsyncMock) -> None:
|
||||
"""Check full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -55,11 +54,9 @@ async def test_full_flow(
|
||||
assert result["title"] == "HomeLink"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_unique_configurations(
|
||||
hass: HomeAssistant,
|
||||
mock_srp_auth: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_srp_auth: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Check full flow."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
@@ -89,12 +86,9 @@ async def test_unique_configurations(
|
||||
(Exception("Some error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_srp_auth: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_srp_auth: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test exceptions are handled correctly."""
|
||||
|
||||
|
||||
@@ -91,13 +91,12 @@ async def test_full_flow(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("current_request_with_host")
|
||||
@pytest.mark.usefixtures("current_request_with_host", "mock_setup_entry")
|
||||
async def test_existing_entry(
|
||||
hass: HomeAssistant,
|
||||
hass_client_no_auth: ClientSessionGenerator,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
mock_geocaching_config_flow: MagicMock,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
setup_credentials: None,
|
||||
) -> None:
|
||||
|
||||
@@ -21,9 +21,9 @@ from .const import MOCK_ACCESS_TOKEN
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_user_flow_implementation(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: None,
|
||||
github_device_client: AsyncMock,
|
||||
github_client: AsyncMock,
|
||||
device_activation_event: asyncio.Event,
|
||||
|
||||
@@ -450,9 +450,9 @@ async def test_reauth_exceptions(
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_same_api_key_different_referrer(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_google_weather_api: AsyncMock,
|
||||
) -> None:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Test the Green Planet Energy config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from greenplanet_energy_api import (
|
||||
GreenPlanetEnergyAPIError,
|
||||
@@ -16,9 +16,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form_create_entry(
|
||||
hass: HomeAssistant, mock_api: MagicMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_create_entry(hass: HomeAssistant, mock_api: MagicMock) -> None:
|
||||
"""Test creating an entry."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -42,12 +41,9 @@ async def test_form_create_entry(
|
||||
(Exception("Unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_errors_and_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_api: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error_base: str,
|
||||
hass: HomeAssistant, mock_api: MagicMock, exception: Exception, error_base: str
|
||||
) -> None:
|
||||
"""Test handling errors and recovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -70,11 +66,9 @@ async def test_form_errors_and_recovery(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_api: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_api: MagicMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test we abort if already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -141,8 +141,9 @@ async def test_auth_form_display(
|
||||
assert field in result["data_schema"].schema
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_incorrect_login(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with incorrect credentials, then recovery."""
|
||||
# Simulate incorrect login
|
||||
@@ -183,8 +184,9 @@ async def test_password_auth_incorrect_login(
|
||||
assert result["data"][CONF_AUTH_TYPE] == AUTH_PASSWORD
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_account_locked(
|
||||
hass: HomeAssistant, mock_growatt_classic_api: MagicMock, mock_setup_entry: None
|
||||
hass: HomeAssistant, mock_growatt_classic_api: MagicMock
|
||||
) -> None:
|
||||
"""Test password authentication when account is locked out."""
|
||||
mock_growatt_classic_api.login.return_value = {
|
||||
@@ -265,8 +267,9 @@ async def test_token_auth_no_plants(hass: HomeAssistant, mock_growatt_v1_api) ->
|
||||
assert result["reason"] == ABORT_NO_PLANTS
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_single_plant(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with single plant."""
|
||||
# Repatch plant_list with full plant data for config flow
|
||||
@@ -294,8 +297,9 @@ async def test_password_auth_single_plant(
|
||||
assert result["result"].unique_id == "123456"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_multiple_plants(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with multiple plants."""
|
||||
# Repatch plant_list with multiple plants
|
||||
@@ -355,12 +359,9 @@ async def test_password_auth_multiple_plants(
|
||||
(V1_API_ERROR_RATE_LIMITED, ERROR_CANNOT_CONNECT),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_token_auth_api_error(
|
||||
hass: HomeAssistant,
|
||||
mock_growatt_v1_api,
|
||||
mock_setup_entry,
|
||||
error_code: int,
|
||||
expected_error: str,
|
||||
hass: HomeAssistant, mock_growatt_v1_api, error_code: int, expected_error: str
|
||||
) -> None:
|
||||
"""Test token authentication with V1 API error maps to correct error type."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -398,8 +399,9 @@ async def test_token_auth_api_error(
|
||||
assert result["data"][CONF_AUTH_TYPE] == AUTH_API_TOKEN
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_token_auth_connection_error(
|
||||
hass: HomeAssistant, mock_growatt_v1_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_v1_api
|
||||
) -> None:
|
||||
"""Test token authentication with network error, then recovery."""
|
||||
|
||||
@@ -438,8 +440,9 @@ async def test_token_auth_connection_error(
|
||||
assert result["data"][CONF_AUTH_TYPE] == AUTH_API_TOKEN
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_token_auth_invalid_response(
|
||||
hass: HomeAssistant, mock_growatt_v1_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_v1_api
|
||||
) -> None:
|
||||
"""Test token authentication with invalid response format, then recovery."""
|
||||
|
||||
@@ -475,8 +478,9 @@ async def test_token_auth_invalid_response(
|
||||
assert result["data"][CONF_AUTH_TYPE] == AUTH_API_TOKEN
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_token_auth_single_plant(
|
||||
hass: HomeAssistant, mock_growatt_v1_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_v1_api
|
||||
) -> None:
|
||||
"""Test token authentication with single plant."""
|
||||
# Repatch plant_list with full plant data for config flow
|
||||
@@ -503,8 +507,9 @@ async def test_token_auth_single_plant(
|
||||
assert result["result"].unique_id == "123456"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_token_auth_multiple_plants(
|
||||
hass: HomeAssistant, mock_growatt_v1_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_v1_api
|
||||
) -> None:
|
||||
"""Test token authentication with multiple plants."""
|
||||
# Repatch plant_list with multiple plants
|
||||
@@ -598,8 +603,9 @@ async def test_token_auth_existing_plant_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_connection_error(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with connection error, then recovery."""
|
||||
# Simulate connection error on first attempt
|
||||
@@ -640,8 +646,9 @@ async def test_password_auth_connection_error(
|
||||
assert result["data"][CONF_AUTH_TYPE] == AUTH_PASSWORD
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_invalid_response(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with invalid response format, then recovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -680,8 +687,9 @@ async def test_password_auth_invalid_response(
|
||||
assert result["data"][CONF_AUTH_TYPE] == AUTH_PASSWORD
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_plant_list_error(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with plant list connection error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -707,8 +715,9 @@ async def test_password_auth_plant_list_error(
|
||||
assert result["reason"] == ERROR_CANNOT_CONNECT
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_password_auth_plant_list_invalid_format(
|
||||
hass: HomeAssistant, mock_growatt_classic_api, mock_setup_entry
|
||||
hass: HomeAssistant, mock_growatt_classic_api
|
||||
) -> None:
|
||||
"""Test password authentication with invalid plant list format."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -50,9 +50,9 @@ async def test_form(
|
||||
(Exception("Unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
expected_error: str,
|
||||
mock_heater: MagicMock,
|
||||
@@ -80,11 +80,9 @@ async def test_form_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_heater: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_heater: MagicMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test we abort if already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -100,11 +98,8 @@ async def test_form_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_dhcp_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_heater: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery(hass: HomeAssistant, mock_heater: MagicMock) -> None:
|
||||
"""Test DHCP discovery shows confirmation form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -135,9 +130,9 @@ async def test_dhcp_discovery(
|
||||
(NoSerialException, "bad_data"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
expected_error: str,
|
||||
mock_heater: MagicMock,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for the Hanna Instruments integration config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from hanna_cloud import AuthenticationError
|
||||
import pytest
|
||||
@@ -15,11 +15,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hanna_client: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_hanna_client: MagicMock) -> None:
|
||||
"""Test full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -61,9 +58,9 @@ async def test_full_flow(
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_error_scenarios(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hanna_client: MagicMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
@@ -100,9 +97,9 @@ async def test_error_scenarios(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hanna_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
|
||||
@@ -4,6 +4,7 @@ from ipaddress import ip_address
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from hdfury import HDFuryError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.hdfury.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
@@ -27,10 +28,9 @@ ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_async_step_user_gets_form_and_creates_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_hdfury_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_hdfury_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test that the we can view the form and that the config flow creates an entry."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -53,10 +53,9 @@ async def test_async_step_user_gets_form_and_creates_entry(
|
||||
assert result["result"].unique_id == "000123456789"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_abort_if_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that we abort if we attempt to submit the same entry twice."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -77,10 +76,9 @@ async def test_abort_if_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_successful_recovery_after_connection_error(
|
||||
hass: HomeAssistant,
|
||||
mock_hdfury_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_hdfury_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test error shown when connection fails."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -110,10 +108,9 @@ async def test_successful_recovery_after_connection_error(
|
||||
assert result["result"].unique_id == "000123456789"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_hdfury_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_hdfury_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -137,10 +134,9 @@ async def test_zeroconf_flow(
|
||||
assert result["result"].unique_id == "000123456789"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_flow_failure(
|
||||
hass: HomeAssistant,
|
||||
mock_hdfury_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_hdfury_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test zeroconf flow failure."""
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.hegel.const import CONF_MODEL, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.const import CONF_HOST
|
||||
@@ -17,10 +19,9 @@ TEST_NAME = "Hegel H190"
|
||||
TEST_SSDP_LOCATION = f"http://{TEST_HOST}:8080/description.xml"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_hegel_client: MagicMock,
|
||||
hass: HomeAssistant, mock_hegel_client: MagicMock
|
||||
) -> None:
|
||||
"""Test successful user flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -46,10 +47,9 @@ async def test_user_flow_success(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_exception(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_hegel_client: MagicMock,
|
||||
hass: HomeAssistant, mock_hegel_client: MagicMock
|
||||
) -> None:
|
||||
"""Test user flow when connection fails."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -108,10 +108,9 @@ async def test_user_flow_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_ssdp_discovery_success(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_hegel_client: MagicMock,
|
||||
hass: HomeAssistant, mock_hegel_client: MagicMock
|
||||
) -> None:
|
||||
"""Test successful SSDP discovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -143,10 +142,9 @@ async def test_ssdp_discovery_success(
|
||||
assert result["result"].unique_id == TEST_UDN
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_ssdp_discovery_from_ssdp_location(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_hegel_client: MagicMock,
|
||||
hass: HomeAssistant, mock_hegel_client: MagicMock
|
||||
) -> None:
|
||||
"""Test SSDP discovery extracts host from ssdp_location when presentationURL is not available."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""Test the Hikvision config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from homeassistant.components.hikvision.const import DOMAIN
|
||||
@@ -28,11 +29,8 @@ from .conftest import (
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form(hass: HomeAssistant, mock_hikcamera: MagicMock) -> None:
|
||||
"""Test we get the form and can create entry."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -69,10 +67,9 @@ async def test_form(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_cannot_connect(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error and can recover."""
|
||||
mock_hikcamera.return_value.get_id = None
|
||||
@@ -113,11 +110,8 @@ async def test_form_cannot_connect(
|
||||
assert result["result"].unique_id == TEST_DEVICE_ID
|
||||
|
||||
|
||||
async def test_form_exception(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_exception(hass: HomeAssistant, mock_hikcamera: MagicMock) -> None:
|
||||
"""Test we handle exception during connection and can recover."""
|
||||
mock_hikcamera.side_effect = requests.exceptions.RequestException(
|
||||
"Connection failed"
|
||||
@@ -161,10 +155,9 @@ async def test_form_exception(
|
||||
assert result["result"].unique_id == TEST_DEVICE_ID
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_unknown_exception(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock
|
||||
) -> None:
|
||||
"""Test we handle unknown exception during connection and can recover."""
|
||||
mock_hikcamera.side_effect = Exception("Unexpected error")
|
||||
@@ -207,11 +200,9 @@ async def test_form_unknown_exception(
|
||||
assert result["result"].unique_id == TEST_DEVICE_ID
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test we handle already configured devices."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -235,11 +226,8 @@ async def test_form_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_import_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow(hass: HomeAssistant, mock_hikcamera: MagicMock) -> None:
|
||||
"""Test YAML import flow creates config entry."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -270,10 +258,9 @@ async def test_import_flow(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow_with_defaults(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock
|
||||
) -> None:
|
||||
"""Test YAML import flow uses default values."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -293,10 +280,9 @@ async def test_import_flow_with_defaults(
|
||||
assert result["data"][CONF_SSL] is False
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow_cannot_connect(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock
|
||||
) -> None:
|
||||
"""Test YAML import flow aborts on connection error."""
|
||||
mock_hikcamera.side_effect = requests.exceptions.RequestException(
|
||||
@@ -319,10 +305,9 @@ async def test_import_flow_cannot_connect(
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow_no_device_id(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock
|
||||
) -> None:
|
||||
"""Test YAML import flow aborts when device_id is None."""
|
||||
mock_hikcamera.return_value.get_id = None
|
||||
@@ -343,10 +328,9 @@ async def test_import_flow_no_device_id(
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow_unknown_exception(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock
|
||||
) -> None:
|
||||
"""Test YAML import flow aborts on unknown exception."""
|
||||
mock_hikcamera.side_effect = Exception("Unexpected error")
|
||||
@@ -367,11 +351,9 @@ async def test_import_flow_unknown_exception(
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_flow_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_hikcamera: MagicMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test YAML import flow aborts when device is already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -392,11 +374,8 @@ async def test_import_flow_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_form_with_ssl(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_hikcamera: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_with_ssl(hass: HomeAssistant, mock_hikcamera: MagicMock) -> None:
|
||||
"""Test user flow with ssl enabled passes ssl parameter to HikCamera."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
||||
@@ -151,9 +151,9 @@ async def test_step_user_errors(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_homevolt_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -235,9 +235,9 @@ async def test_credentials_step_invalid_password(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_success(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_homevolt_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -275,9 +275,9 @@ async def test_reauth_success(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_homevolt_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
@@ -341,9 +341,9 @@ async def test_zeroconf_confirm_flow_success(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_duplicate_aborts(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_homevolt_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -451,9 +451,9 @@ async def test_zeroconf_confirm_with_password_invalid_then_success(
|
||||
],
|
||||
ids=["connection_error", "unknown_error"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_error_aborts(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_homevolt_client: MagicMock,
|
||||
exception: Exception,
|
||||
expected_reason: str,
|
||||
|
||||
@@ -31,9 +31,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_user_flow(
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock, mock_setup_entry
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow(hass: HomeAssistant, mock_homeworks: MagicMock) -> None:
|
||||
"""Test the user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -65,8 +64,9 @@ async def test_user_flow(
|
||||
mock_controller.join.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_credentials(
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock, mock_setup_entry
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock
|
||||
) -> None:
|
||||
"""Test the user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -103,8 +103,9 @@ async def test_user_flow_credentials(
|
||||
mock_controller.join.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_credentials_user_only(
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock, mock_setup_entry
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock
|
||||
) -> None:
|
||||
"""Test the user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -138,8 +139,9 @@ async def test_user_flow_credentials_user_only(
|
||||
mock_controller.join.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_credentials_password_only(
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock, mock_setup_entry
|
||||
hass: HomeAssistant, mock_homeworks: MagicMock
|
||||
) -> None:
|
||||
"""Test the user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -163,8 +165,9 @@ async def test_user_flow_credentials_password_only(
|
||||
assert result["errors"] == {"base": "need_username_with_password"}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_already_exists(
|
||||
hass: HomeAssistant, mock_empty_config_entry: MockConfigEntry, mock_setup_entry
|
||||
hass: HomeAssistant, mock_empty_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test the user configuration flow."""
|
||||
mock_empty_config_entry.add_to_hass(hass)
|
||||
@@ -208,10 +211,10 @@ async def test_user_flow_already_exists(
|
||||
(Exception, "unknown_error"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_cannot_connect(
|
||||
hass: HomeAssistant,
|
||||
mock_homeworks: MagicMock,
|
||||
mock_setup_entry,
|
||||
side_effect: type[Exception],
|
||||
error: str,
|
||||
) -> None:
|
||||
|
||||
@@ -13,11 +13,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_qube_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_qube_client: MagicMock) -> None:
|
||||
"""Test successful config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -43,10 +40,10 @@ async def test_full_flow(
|
||||
(None, True, None, "not_qube_device"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_qube_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
connect_side_effect: type[Exception] | None,
|
||||
connect_result: bool | None,
|
||||
version_result: str | None,
|
||||
@@ -82,11 +79,9 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_qube_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_qube_client: MagicMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test we abort when device is already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -101,10 +101,9 @@ async def test_user_form(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("discovery_info", [[NOT_HUE_BLE_DISCOVERY_INFO], []])
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_form_no_device(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
discovery_info: list[BluetoothServiceInfoBleak],
|
||||
hass: HomeAssistant, discovery_info: list[BluetoothServiceInfoBleak]
|
||||
) -> None:
|
||||
"""Test user form with no devices."""
|
||||
|
||||
@@ -198,9 +197,9 @@ async def test_user_form_no_device(
|
||||
"unknown",
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_form_exception(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_return_device: BLEDevice | None,
|
||||
mock_scanner_count: int,
|
||||
mock_connect: Exception | None,
|
||||
@@ -292,10 +291,8 @@ async def test_user_form_exception(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_bluetooth_discovery_aborts(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_bluetooth_discovery_aborts(hass: HomeAssistant) -> None:
|
||||
"""Test bluetooth form aborts."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -307,10 +304,9 @@ async def test_bluetooth_discovery_aborts(
|
||||
assert result["reason"] == "discovery_unsupported"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_bluetooth_form_exception_already_set_up(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test bluetooth discovery form when device is already set up."""
|
||||
|
||||
@@ -325,10 +321,9 @@ async def test_bluetooth_form_exception_already_set_up(
|
||||
assert result["reason"] == "discovery_unsupported"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_form_exception_already_set_up(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test user form when device is already set up."""
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ async def test_form_homekit_and_dhcp(
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_hunterdouglas_hub")
|
||||
@pytest.mark.usefixtures("mock_hunterdouglas_hub", "mock_setup_entry")
|
||||
@pytest.mark.parametrize(
|
||||
("homekit_source", "homekit_discovery", "api_version"), HOMEKIT_DATA
|
||||
)
|
||||
@@ -165,7 +165,6 @@ async def test_form_homekit_and_dhcp(
|
||||
)
|
||||
async def test_discovered_by_homekit_and_dhcp(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
homekit_source: str,
|
||||
homekit_discovery: ZeroconfServiceInfo,
|
||||
api_version: int,
|
||||
|
||||
@@ -45,11 +45,9 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_huum_client")
|
||||
@pytest.mark.usefixtures("mock_huum_client", "mock_setup_entry")
|
||||
async def test_signup_flow_already_set_up(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that we handle already existing entities with same id."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -79,12 +77,9 @@ async def test_signup_flow_already_set_up(
|
||||
(Forbidden, "invalid_auth"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_huum_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_huum_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
raises: Exception,
|
||||
error_base: str,
|
||||
hass: HomeAssistant, mock_huum_client: AsyncMock, raises: Exception, error_base: str
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -255,10 +250,10 @@ async def test_reconfigure_flow_already_configured(
|
||||
(Forbidden, "invalid_auth"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_huum_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
raises: Exception,
|
||||
error_base: str,
|
||||
|
||||
@@ -64,12 +64,9 @@ async def test_step_user(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_user_error_handling(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_immich: Mock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_immich: Mock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test a user initiated config flow with errors."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -98,9 +95,8 @@ async def test_step_user_error_handling(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_step_user_invalid_url(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_immich: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_user_invalid_url(hass: HomeAssistant, mock_immich: Mock) -> None:
|
||||
"""Test a user initiated config flow with errors."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -144,11 +140,9 @@ async def test_user_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_immich: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_immich: Mock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauthentication flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -227,11 +221,9 @@ async def test_reauth_flow_error_handling(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_mismatch(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_immich: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_immich: Mock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauthentication flow with mis-matching unique id."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -251,11 +243,9 @@ async def test_reauth_flow_mismatch(
|
||||
assert result["reason"] == "unique_id_mismatch"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_immich: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_immich: Mock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -294,9 +284,9 @@ async def test_reconfigure_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_reconfigure_error_handling(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_immich: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
@@ -328,11 +318,9 @@ async def test_step_reconfigure_error_handling(
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_step_reconfigure_invalid_url(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_immich: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_immich: Mock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test a user initiated config flow with errors."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -23,9 +23,8 @@ from tests.common import MockConfigEntry
|
||||
TEST_HOST_NEW = "192.168.1.200"
|
||||
|
||||
|
||||
async def test_user_flow_success(
|
||||
hass: HomeAssistant, mock_indevolt: AsyncMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_success(hass: HomeAssistant, mock_indevolt: AsyncMock) -> None:
|
||||
"""Test successful user-initiated config flow."""
|
||||
|
||||
# Initiate user flow
|
||||
@@ -63,10 +62,10 @@ async def test_user_flow_success(
|
||||
(Exception("Some unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_error(
|
||||
hass: HomeAssistant,
|
||||
mock_indevolt: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -119,11 +118,9 @@ async def test_user_flow_duplicate_entry(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_indevolt: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_indevolt: AsyncMock
|
||||
) -> None:
|
||||
"""Test successful reconfiguration flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -165,11 +162,11 @@ async def test_reconfigure_flow_success(
|
||||
(Exception("Some unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_error(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_indevolt: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -206,11 +203,9 @@ async def test_reconfigure_flow_error(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_different_device(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_indevolt: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_indevolt: AsyncMock
|
||||
) -> None:
|
||||
"""Test reconfigure aborts when connecting to a different device."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -152,9 +152,9 @@ def patch_file_upload(return_value=PATH_FIXTURE, side_effect=None):
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_setup_v1(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
config_url: dict[str, Any],
|
||||
@@ -223,9 +223,9 @@ async def test_setup_v1(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_setup_v1_ssl_cert(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
config_url: dict[str, Any],
|
||||
@@ -291,9 +291,9 @@ async def test_setup_v1_ssl_cert(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_setup_v2(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
get_write_api: Any,
|
||||
@@ -352,9 +352,9 @@ async def test_setup_v2(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_setup_v2_ssl_cert(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
get_write_api: Any,
|
||||
@@ -510,9 +510,9 @@ async def test_setup_v2_ssl_cert(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_setup_connection_error(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
api_version: str,
|
||||
@@ -569,9 +569,9 @@ async def test_setup_connection_error(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_single_instance(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
get_write_api: Any,
|
||||
@@ -615,9 +615,9 @@ async def test_single_instance(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
get_write_api: Any,
|
||||
@@ -719,9 +719,9 @@ async def test_import_connection_error(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_single_instance_import(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
config_base: dict[str, Any],
|
||||
get_write_api: Any,
|
||||
@@ -819,9 +819,9 @@ async def test_single_instance_import(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_v1(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
entry_data: dict[str, Any],
|
||||
user_input: dict[str, Any],
|
||||
@@ -884,9 +884,9 @@ async def test_reconfigure_v1(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_v2(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
entry_data: dict[str, Any],
|
||||
user_input: dict[str, Any],
|
||||
@@ -945,9 +945,9 @@ async def test_reconfigure_v2(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_v1_ssl_cert(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
entry_data: dict[str, Any],
|
||||
user_input: dict[str, Any],
|
||||
@@ -1001,9 +1001,9 @@ async def test_reconfigure_v1_ssl_cert(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_v2_ssl_cert(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
entry_data: dict[str, Any],
|
||||
user_input: dict[str, Any],
|
||||
@@ -1078,9 +1078,9 @@ async def test_reconfigure_v2_ssl_cert(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_preserves_existing_cert(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
entry_data: dict[str, Any],
|
||||
user_input: dict[str, Any],
|
||||
@@ -1180,9 +1180,9 @@ async def test_reconfigure_preserves_existing_cert(
|
||||
],
|
||||
indirect=["mock_client"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_connection_error(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_client: MagicMock,
|
||||
entry_data: dict[str, Any],
|
||||
user_input: dict[str, Any],
|
||||
|
||||
@@ -23,9 +23,8 @@ DATA_CONFIG = {
|
||||
}
|
||||
|
||||
|
||||
async def test_user_flow(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_cloud_interface
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow(hass: HomeAssistant, mock_cloud_interface) -> None:
|
||||
"""Test the full config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -53,9 +52,9 @@ async def test_user_flow(
|
||||
(RuntimeError("Unexpected error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_auth_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_cloud_interface: AsyncMock,
|
||||
side_effect: Exception,
|
||||
error: str,
|
||||
@@ -86,9 +85,9 @@ async def test_form_auth_errors(
|
||||
assert result["data"] == DATA_CONFIG
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_no_devices(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_cloud_interface: AsyncMock,
|
||||
single_eco_device: IntelliClimaDevices,
|
||||
) -> None:
|
||||
@@ -121,9 +120,9 @@ async def test_form_no_devices(
|
||||
assert result["data"] == DATA_CONFIG
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_cloud_interface: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""Test the IntelliFire config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from intellifire4py.exceptions import LoginError
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.intellifire.const import (
|
||||
@@ -21,10 +20,9 @@ from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_standard_config_with_single_fireplace(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_apis_single_fp,
|
||||
hass: HomeAssistant, mock_apis_single_fp
|
||||
) -> None:
|
||||
"""Test standard flow with a user who has only a single fireplace."""
|
||||
|
||||
@@ -53,11 +51,9 @@ async def test_standard_config_with_single_fireplace(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_standard_config_with_pre_configured_fireplace(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry_current,
|
||||
mock_apis_single_fp,
|
||||
hass: HomeAssistant, mock_config_entry_current, mock_apis_single_fp
|
||||
) -> None:
|
||||
"""What if we try to configure an already configured fireplace."""
|
||||
# Configure an existing entry
|
||||
@@ -80,10 +76,9 @@ async def test_standard_config_with_pre_configured_fireplace(
|
||||
assert result["reason"] == "no_available_devices"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_standard_config_with_single_fireplace_and_bad_credentials(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_apis_single_fp,
|
||||
hass: HomeAssistant, mock_apis_single_fp
|
||||
) -> None:
|
||||
"""Test bad credentials on a login."""
|
||||
_mock_local_interface, mock_cloud_interface, _mock_fp = mock_apis_single_fp
|
||||
@@ -126,10 +121,9 @@ async def test_standard_config_with_single_fireplace_and_bad_credentials(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_standard_config_with_multiple_fireplace(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_apis_multifp,
|
||||
hass: HomeAssistant, mock_apis_multifp
|
||||
) -> None:
|
||||
"""Test multi-fireplace user who must be very rich."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -163,10 +157,9 @@ async def test_standard_config_with_multiple_fireplace(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_intellifire_device(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_apis_multifp,
|
||||
hass: HomeAssistant, mock_apis_multifp
|
||||
) -> None:
|
||||
"""Test successful DHCP Discovery."""
|
||||
|
||||
@@ -189,10 +182,9 @@ async def test_dhcp_discovery_intellifire_device(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_non_intellifire_device(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_apis_multifp,
|
||||
hass: HomeAssistant, mock_apis_multifp
|
||||
) -> None:
|
||||
"""Test successful DHCP Discovery of a non intellifire device.."""
|
||||
|
||||
@@ -214,11 +206,9 @@ async def test_dhcp_discovery_non_intellifire_device(
|
||||
# Test is finished - the DHCP scanner detected a hostname that "might" be an IntelliFire device, but it was not.
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry_current: MockConfigEntry,
|
||||
mock_apis_single_fp,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry_current: MockConfigEntry, mock_apis_single_fp
|
||||
) -> None:
|
||||
"""Test reauth."""
|
||||
|
||||
|
||||
@@ -132,10 +132,10 @@ async def test_zeroconf_flow_abort_errors(
|
||||
],
|
||||
ids=["status-connection", "status-missing", "reading-missing"],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_iometer_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
method_name: str,
|
||||
exception: Exception,
|
||||
error_key: str,
|
||||
@@ -169,10 +169,10 @@ async def test_user_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_abort_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_iometer_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.irm_kmi.const import CONF_LANGUAGE_OVERRIDE, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
@@ -16,10 +18,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_user_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_get_forecast_in_benelux: MagicMock,
|
||||
hass: HomeAssistant, mock_get_forecast_in_benelux: MagicMock
|
||||
) -> None:
|
||||
"""Test the full user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -41,10 +42,9 @@ async def test_full_user_flow(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_home(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_get_forecast_in_benelux: MagicMock,
|
||||
hass: HomeAssistant, mock_get_forecast_in_benelux: MagicMock
|
||||
) -> None:
|
||||
"""Test the full user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -59,10 +59,9 @@ async def test_user_flow_home(
|
||||
assert result.get("title") == "Brussels"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_config_flow_location_out_benelux(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_get_forecast_out_benelux_then_in_belgium: MagicMock,
|
||||
hass: HomeAssistant, mock_get_forecast_out_benelux_then_in_belgium: MagicMock
|
||||
) -> None:
|
||||
"""Test configuration flow with a zone outside of Benelux."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -85,10 +84,9 @@ async def test_config_flow_location_out_benelux(
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_config_flow_with_api_error(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_get_forecast_api_error: MagicMock,
|
||||
hass: HomeAssistant, mock_get_forecast_api_error: MagicMock
|
||||
) -> None:
|
||||
"""Test when API returns an error during the configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -103,10 +101,9 @@ async def test_config_flow_with_api_error(
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_setup_twice_same_location(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
mock_get_forecast_in_benelux: MagicMock,
|
||||
hass: HomeAssistant, mock_get_forecast_in_benelux: MagicMock
|
||||
) -> None:
|
||||
"""Test when the user tries to set up the weather twice for the same location."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.israel_rail import CONF_DESTINATION, CONF_START, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -12,9 +14,8 @@ from .conftest import VALID_CONFIG
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_create_entry(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_israelrail: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_create_entry(hass: HomeAssistant, mock_israelrail: AsyncMock) -> None:
|
||||
"""Test that the user step works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -34,11 +35,8 @@ async def test_create_entry(
|
||||
}
|
||||
|
||||
|
||||
async def test_flow_fails(
|
||||
hass: HomeAssistant,
|
||||
mock_israelrail: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_fails(hass: HomeAssistant, mock_israelrail: AsyncMock) -> None:
|
||||
"""Test that the user step fails."""
|
||||
mock_israelrail.query.side_effect = Exception("error")
|
||||
failed_result = await hass.config_entries.flow.async_init(
|
||||
@@ -65,11 +63,9 @@ async def test_flow_fails(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_israelrail: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_israelrail: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that the user step fails when the entry is already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -64,9 +64,8 @@ async def __do_successful_otp_step(
|
||||
return result
|
||||
|
||||
|
||||
async def test_full_user_flow(
|
||||
hass: HomeAssistant, mock_ituran: AsyncMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_user_flow(hass: HomeAssistant, mock_ituran: AsyncMock) -> None:
|
||||
"""Test the full user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -79,9 +78,8 @@ async def test_full_user_flow(
|
||||
await __do_successful_otp_step(hass, result, mock_ituran)
|
||||
|
||||
|
||||
async def test_invalid_auth(
|
||||
hass: HomeAssistant, mock_ituran: AsyncMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_invalid_auth(hass: HomeAssistant, mock_ituran: AsyncMock) -> None:
|
||||
"""Test invalid credentials configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -108,9 +106,8 @@ async def test_invalid_auth(
|
||||
await __do_successful_otp_step(hass, result, mock_ituran)
|
||||
|
||||
|
||||
async def test_invalid_otp(
|
||||
hass: HomeAssistant, mock_ituran: AsyncMock, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_invalid_otp(hass: HomeAssistant, mock_ituran: AsyncMock) -> None:
|
||||
"""Test invalid OTP configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -140,10 +137,10 @@ async def test_invalid_otp(
|
||||
("exception", "expected_error"),
|
||||
[(IturanApiError, "cannot_connect"), (Exception, "unknown")],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_ituran: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -186,8 +183,9 @@ async def test_errors(
|
||||
await __do_successful_otp_step(hass, result, mock_ituran)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_authenticated(
|
||||
hass: HomeAssistant, mock_ituran: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_ituran: AsyncMock
|
||||
) -> None:
|
||||
"""Test user already authenticated configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -214,11 +212,9 @@ async def test_already_authenticated(
|
||||
assert result["result"].unique_id == MOCK_CONFIG_DATA[CONF_ID_OR_PASSPORT]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth(
|
||||
hass: HomeAssistant,
|
||||
mock_ituran: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_ituran: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauthenticating."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -94,12 +94,9 @@ async def test_user_flow_creates_entry(
|
||||
(Exception(), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_errors_and_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_kiosker_api: MagicMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_kiosker_api: MagicMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test user flow handles all validation errors and can recover."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -256,10 +253,9 @@ async def test_zeroconf_abort_if_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_no_device_id(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_kiosker_api: MagicMock,
|
||||
hass: HomeAssistant, mock_kiosker_api: MagicMock
|
||||
) -> None:
|
||||
"""Test user flow shows cannot_connect error when device reports no device ID."""
|
||||
mock_kiosker_api.status.return_value.device_id = None
|
||||
|
||||
@@ -88,10 +88,10 @@ async def test_duplcate_entry(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_knocki_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
field: str,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -123,11 +123,8 @@ async def test_exceptions(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_dhcp(
|
||||
hass: HomeAssistant,
|
||||
mock_knocki_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp(hass: HomeAssistant, mock_knocki_client: AsyncMock) -> None:
|
||||
"""Test DHCP discovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_DHCP}, data=DHCP_DISCOVERY
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Tests for the LaMetric config flow."""
|
||||
|
||||
from http import HTTPStatus
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from demetriek import (
|
||||
LaMetricConnectionError,
|
||||
@@ -683,10 +683,9 @@ async def test_cloud_errors(
|
||||
assert len(mock_lametric.notify.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_updates_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test DHCP discovery updates config entries."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -4,6 +4,7 @@ import dataclasses
|
||||
from ipaddress import ip_address
|
||||
|
||||
from lektricowifi import DeviceConnectionError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.lektrico.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
@@ -115,9 +116,8 @@ async def test_user_setup_device_offline(hass: HomeAssistant, mock_device) -> No
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_discovered_zeroconf(
|
||||
hass: HomeAssistant, mock_device, mock_setup_entry
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_discovered_zeroconf(hass: HomeAssistant, mock_device) -> None:
|
||||
"""Test we can setup when discovered from zeroconf."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -137,11 +137,9 @@ async def test_flow_duplicate(
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_client: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauth flow with success."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -182,10 +180,10 @@ async def test_reauth_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -232,11 +230,9 @@ async def test_reauth_exceptions(
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_different_user_id_new(
|
||||
hass: HomeAssistant,
|
||||
mock_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_client: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauth flow with different, new user ID updating the existing entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -270,11 +266,9 @@ async def test_reauth_different_user_id_new(
|
||||
assert config_entries[0].unique_id == "new_user_id"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_different_user_id_existing(
|
||||
hass: HomeAssistant,
|
||||
mock_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_client: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauth flow with different, existing user ID aborting."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.lg_thinq.const import CONF_CONNECT_CLIENT_ID, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY
|
||||
@@ -21,11 +23,9 @@ DHCP_DISCOVERY = DhcpServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_config_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_config_thinq_api: AsyncMock,
|
||||
mock_uuid: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_thinq_api: AsyncMock, mock_uuid: AsyncMock
|
||||
) -> None:
|
||||
"""Test that an thinq entry is normally created."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -79,11 +79,9 @@ async def test_config_flow_already_configured(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_config_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_config_thinq_api: AsyncMock,
|
||||
mock_uuid: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_thinq_api: AsyncMock, mock_uuid: AsyncMock
|
||||
) -> None:
|
||||
"""Test that a thinq entry is normally created."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -62,9 +62,9 @@ async def test_form(
|
||||
(Exception("Unexpected"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_errors_with_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_liebherr_client: MagicMock,
|
||||
side_effect: Exception,
|
||||
expected_error: str,
|
||||
@@ -132,10 +132,9 @@ async def test_form_already_configured(
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_zeroconf_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_liebherr_client: MagicMock,
|
||||
hass: HomeAssistant, mock_liebherr_client: MagicMock
|
||||
) -> None:
|
||||
"""Test zeroconf discovery triggers the config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -170,9 +169,9 @@ async def test_zeroconf_already_configured(
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_liebherr_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
@@ -200,9 +199,9 @@ async def test_reauth_flow(
|
||||
(Exception("Unexpected"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_errors_with_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_liebherr_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
side_effect: Exception,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for the LoJack config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from lojack_api import ApiError, AuthenticationError
|
||||
import pytest
|
||||
@@ -16,10 +16,9 @@ from .const import TEST_PASSWORD, TEST_USER_ID, TEST_USERNAME
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_user_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_lojack_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_lojack_client: MagicMock
|
||||
) -> None:
|
||||
"""Test the full user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -53,10 +52,10 @@ async def test_full_user_flow(
|
||||
(Exception("Unknown error"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_lojack_client: MagicMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
|
||||
@@ -15,8 +15,9 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_validate_input_success(
|
||||
hass: HomeAssistant, mock_setup_entry, mock_london_underground_client
|
||||
hass: HomeAssistant, mock_london_underground_client
|
||||
) -> None:
|
||||
"""Test successful validation of TfL API."""
|
||||
|
||||
@@ -38,9 +39,8 @@ async def test_validate_input_success(
|
||||
assert result["options"] == {CONF_LINE: ["Bakerloo", "Central"]}
|
||||
|
||||
|
||||
async def test_options(
|
||||
hass: HomeAssistant, mock_setup_entry, mock_config_entry
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_options(hass: HomeAssistant, mock_config_entry) -> None:
|
||||
"""Test updating options."""
|
||||
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
|
||||
|
||||
@@ -67,12 +67,9 @@ async def test_options(
|
||||
(asyncio.TimeoutError, "timeout_connect"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_validate_input_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry,
|
||||
mock_london_underground_client,
|
||||
side_effect,
|
||||
expected_error,
|
||||
hass: HomeAssistant, mock_london_underground_client, side_effect, expected_error
|
||||
) -> None:
|
||||
"""Test validation with connection and timeout errors."""
|
||||
|
||||
@@ -104,11 +101,9 @@ async def test_validate_input_exceptions(
|
||||
assert result["options"] == {CONF_LINE: DEFAULT_LINES}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_london_underground_client,
|
||||
mock_setup_entry,
|
||||
mock_config_entry,
|
||||
hass: HomeAssistant, mock_london_underground_client, mock_config_entry
|
||||
) -> None:
|
||||
"""Try (and fail) setting up a config entry when one already exists."""
|
||||
|
||||
|
||||
@@ -45,11 +45,9 @@ ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("info_data"), [INFO_DATA, LEGACY_INFO_DATA])
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_lunatone_info: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
info_data: InfoData,
|
||||
hass: HomeAssistant, mock_lunatone_info: AsyncMock, info_data: InfoData
|
||||
) -> None:
|
||||
"""Test full user flow."""
|
||||
mock_lunatone_info.set_data(info_data)
|
||||
@@ -120,10 +118,10 @@ async def test_device_already_configured(
|
||||
(aiohttp.ClientConnectionError(), "cannot_connect"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_step_fail_with_error(
|
||||
hass: HomeAssistant,
|
||||
mock_lunatone_info: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -227,10 +225,10 @@ async def test_zeroconf_flow_abort_with_error(
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure(
|
||||
hass: HomeAssistant,
|
||||
mock_lunatone_info: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
@@ -257,10 +255,10 @@ async def test_reconfigure(
|
||||
(aiohttp.ClientConnectionError(), "cannot_connect"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Test the lutron config flow."""
|
||||
|
||||
from email.message import Message
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
from urllib.error import HTTPError
|
||||
|
||||
import pytest
|
||||
@@ -21,7 +21,8 @@ MOCK_DATA_STEP = {
|
||||
}
|
||||
|
||||
|
||||
async def test_full_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant) -> None:
|
||||
"""Test success response."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -52,11 +53,9 @@ async def test_full_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_failure(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
raise_error: Exception,
|
||||
text_error: str,
|
||||
hass: HomeAssistant, raise_error: Exception, text_error: str
|
||||
) -> None:
|
||||
"""Test unknown errors."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -93,9 +92,8 @@ async def test_flow_failure(
|
||||
assert result["data"] == MOCK_DATA_STEP
|
||||
|
||||
|
||||
async def test_flow_incorrect_guid(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_incorrect_guid(hass: HomeAssistant) -> None:
|
||||
"""Test configuring flow with incorrect guid."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
||||
@@ -23,11 +23,8 @@ async def avoid_wait() -> AsyncGenerator[None]:
|
||||
yield
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_madvr_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_madvr_client: AsyncMock) -> None:
|
||||
"""Test full config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
@@ -51,11 +48,8 @@ async def test_full_flow(
|
||||
mock_madvr_client.async_cancel_tasks.assert_called_once()
|
||||
|
||||
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_madvr_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(hass: HomeAssistant, mock_madvr_client: AsyncMock) -> None:
|
||||
"""Test error handling in config flow."""
|
||||
mock_madvr_client.open_connection.side_effect = TimeoutError
|
||||
|
||||
|
||||
@@ -18,11 +18,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_mastodon_client: AsyncMock) -> None:
|
||||
"""Test full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -51,10 +48,9 @@ async def test_full_flow(
|
||||
assert result["result"].unique_id == "trwnh_mastodon_social"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow_with_path(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_mastodon_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full flow, where a path is accidentally specified."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -84,10 +80,9 @@ async def test_full_flow_with_path(
|
||||
assert result["result"].unique_id == "trwnh_mastodon_social"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow_fallback_to_instance_v1(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_mastodon_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test full flow where instance_v2 fails and falls back to instance_v1."""
|
||||
mock_mastodon_client.instance_v2.side_effect = MastodonNotFoundError(
|
||||
@@ -132,10 +127,10 @@ async def test_full_flow_fallback_to_instance_v1(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
) -> None:
|
||||
@@ -176,10 +171,10 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
@@ -206,10 +201,10 @@ async def test_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reauth flow."""
|
||||
@@ -229,10 +224,10 @@ async def test_reauth_flow(
|
||||
assert mock_config_entry.data[CONF_ACCESS_TOKEN] == "token2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_wrong_account(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reauth flow with wrong account."""
|
||||
@@ -263,10 +258,10 @@ async def test_reauth_flow_wrong_account(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -298,10 +293,10 @@ async def test_reauth_flow_exceptions(
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
@@ -328,10 +323,10 @@ async def test_reconfigure_flow(
|
||||
assert mock_config_entry.data[CONF_ACCESS_TOKEN] == "access_token2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_wrong_account(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow with wrong account."""
|
||||
@@ -366,10 +361,10 @@ async def test_reconfigure_flow_wrong_account(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_mastodon_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
|
||||
@@ -219,9 +219,8 @@ async def test_input_form_validation_error(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_unique_url(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_mcp_client: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_unique_url(hass: HomeAssistant, mock_mcp_client: Mock) -> None:
|
||||
"""Test that the same url cannot be configured twice."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
@@ -251,10 +250,9 @@ async def test_unique_url(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_server_missing_capbilities(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mcp_client: Mock,
|
||||
hass: HomeAssistant, mock_mcp_client: Mock
|
||||
) -> None:
|
||||
"""Test we handle different client library errors."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -277,10 +275,9 @@ async def test_server_missing_capbilities(
|
||||
|
||||
|
||||
@respx.mock
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_oauth_discovery_flow_without_credentials(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mcp_client: Mock,
|
||||
hass: HomeAssistant, mock_mcp_client: Mock
|
||||
) -> None:
|
||||
"""Test for an OAuth discoveryflow for an MCP server where the user has not yet entered credentials."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -582,7 +579,7 @@ async def test_authentication_discovery_via_header(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("current_request_with_host")
|
||||
@pytest.mark.usefixtures("current_request_with_host", "mock_setup_entry")
|
||||
@respx.mock
|
||||
@pytest.mark.parametrize(
|
||||
("resource_metadata"),
|
||||
@@ -616,7 +613,6 @@ async def test_authentication_discovery_via_header(
|
||||
)
|
||||
async def test_invalid_protected_resource_metadata(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mcp_client: Mock,
|
||||
credential: None,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
@@ -676,11 +672,10 @@ async def test_invalid_protected_resource_metadata(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("current_request_with_host")
|
||||
@pytest.mark.usefixtures("current_request_with_host", "mock_setup_entry")
|
||||
@respx.mock
|
||||
async def test_oauth_discovery_failure(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mcp_client: Mock,
|
||||
credential: None,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
@@ -722,11 +717,10 @@ async def test_oauth_discovery_failure(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("current_request_with_host")
|
||||
@pytest.mark.usefixtures("current_request_with_host", "mock_setup_entry")
|
||||
@respx.mock
|
||||
async def test_authentication_flow_server_failure_abort(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mcp_client: Mock,
|
||||
credential: None,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
@@ -780,11 +774,10 @@ async def test_authentication_flow_server_failure_abort(
|
||||
assert result["reason"] == expected_error
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("current_request_with_host")
|
||||
@pytest.mark.usefixtures("current_request_with_host", "mock_setup_entry")
|
||||
@respx.mock
|
||||
async def test_authentication_flow_server_missing_tool_capabilities(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mcp_client: Mock,
|
||||
credential: None,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
|
||||
@@ -47,11 +47,9 @@ async def test_form(
|
||||
({CONF_LLM_HASS_API: []}, {CONF_LLM_HASS_API: "llm_api_required"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_form_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
params: dict[str, Any],
|
||||
errors: dict[str, str],
|
||||
hass: HomeAssistant, params: dict[str, Any], errors: dict[str, str]
|
||||
) -> None:
|
||||
"""Test we get the errors on invalid user input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -17,11 +17,8 @@ from . import setup_integration
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_flow(hass: HomeAssistant, mock_mealie_client: AsyncMock) -> None:
|
||||
"""Test full flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -52,12 +49,9 @@ async def test_full_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_mealie_client: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test flow errors."""
|
||||
mock_mealie_client.get_user_info.side_effect = exception
|
||||
@@ -86,11 +80,8 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_ingress_host(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_ingress_host(hass: HomeAssistant, mock_mealie_client: AsyncMock) -> None:
|
||||
"""Test disallow ingress host."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -130,11 +121,9 @@ async def test_ingress_host(
|
||||
("v2.0.0beta-2"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_version_error(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
version,
|
||||
hass: HomeAssistant, mock_mealie_client: AsyncMock, version
|
||||
) -> None:
|
||||
"""Test flow version error."""
|
||||
mock_mealie_client.get_about.return_value = About(version=version)
|
||||
@@ -155,10 +144,10 @@ async def test_flow_version_error(
|
||||
assert result["errors"] == {"base": "mealie_version"}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test duplicate flow."""
|
||||
@@ -180,10 +169,10 @@ async def test_duplicate(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reauth flow."""
|
||||
@@ -203,10 +192,10 @@ async def test_reauth_flow(
|
||||
assert mock_config_entry.data[CONF_API_TOKEN] == "token2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_wrong_account(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reauth flow with wrong account."""
|
||||
@@ -235,10 +224,10 @@ async def test_reauth_flow_wrong_account(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reauth_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -270,10 +259,10 @@ async def test_reauth_flow_exceptions(
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow."""
|
||||
@@ -299,10 +288,10 @@ async def test_reconfigure_flow(
|
||||
assert mock_config_entry.data[CONF_VERIFY_SSL] is False
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_wrong_account(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reconfigure flow with wrong account."""
|
||||
@@ -331,10 +320,10 @@ async def test_reconfigure_flow_wrong_account(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_reconfigure_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
@@ -366,10 +355,10 @@ async def test_reconfigure_flow_exceptions(
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_hassio_success(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test successful Supervisor flow."""
|
||||
@@ -459,12 +448,9 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_hassio_connection_error(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_mealie_client: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test flow errors."""
|
||||
mock_mealie_client.get_user_info.side_effect = exception
|
||||
|
||||
@@ -46,12 +46,9 @@ async def test_user_flow(
|
||||
(Exception, "unknown_auth_error"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_exceptions(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_meater_client: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_meater_client: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test that an invalid API/App Key throws an error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for Mill config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -16,9 +16,7 @@ from tests.common import MockConfigEntry
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
|
||||
|
||||
async def test_show_config_form(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
async def test_show_config_form(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test show configuration form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -28,9 +26,7 @@ async def test_show_config_form(
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
async def test_create_entry(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
async def test_create_entry(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test create entry from user input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -66,7 +62,7 @@ async def test_create_entry(
|
||||
|
||||
|
||||
async def test_flow_entry_already_exists(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test user input for config_entry that already exists."""
|
||||
|
||||
@@ -107,9 +103,7 @@ async def test_flow_entry_already_exists(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_connection_error(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
async def test_connection_error(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test connection error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -138,9 +132,7 @@ async def test_connection_error(
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_local_create_entry(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
async def test_local_create_entry(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test create entry from user input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -181,7 +173,7 @@ async def test_local_create_entry(
|
||||
|
||||
|
||||
async def test_local_flow_entry_already_exists(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test user input for config_entry that already exists."""
|
||||
|
||||
@@ -233,7 +225,7 @@ async def test_local_flow_entry_already_exists(
|
||||
|
||||
|
||||
async def test_local_connection_error(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test connection error."""
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from requests_mock import Mocker
|
||||
|
||||
@@ -215,11 +216,9 @@ async def test_connection_error(
|
||||
assert mock_mjpeg_requests.call_count == 5
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_already_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_mjpeg_requests: Mocker,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_mjpeg_requests: Mocker, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test we abort if the MJPEG IP Camera is already configured."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from monarchmoney import LoginFailedException, RequireMFAException
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.monarch_money.const import CONF_MFA_CODE, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
@@ -38,11 +39,9 @@ async def test_form_simple(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_add_duplicate_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_api: AsyncMock,
|
||||
hass: HomeAssistant, mock_config_entry, mock_config_api: AsyncMock
|
||||
) -> None:
|
||||
"""Test a duplicate error config flow."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for the Moon config flow."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.moon.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
@@ -10,10 +10,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_full_user_flow(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: MagicMock,
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_full_user_flow(hass: HomeAssistant) -> None:
|
||||
"""Test the full user configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
||||
@@ -53,12 +53,9 @@ async def test_full_flow(
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_mpd_client: AsyncMock,
|
||||
exception: Exception,
|
||||
error: str,
|
||||
hass: HomeAssistant, mock_mpd_client: AsyncMock, exception: Exception, error: str
|
||||
) -> None:
|
||||
"""Test we handle errors correctly."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
@@ -35,10 +35,9 @@ def make_client_response_error(status: int) -> ClientResponseError:
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_pyaxenco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
hass: HomeAssistant, mock_pyaxenco_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test successful user flow for MyNeomitis integration."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -72,10 +71,10 @@ async def test_user_flow_success(
|
||||
(RuntimeError("boom"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_flow_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_pyaxenco_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
|
||||
@@ -26,7 +26,7 @@ DHCP_SERVICE_INFO = DhcpServiceInfo(
|
||||
)
|
||||
|
||||
|
||||
async def test_form_combined(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
async def test_form_combined(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
@@ -53,7 +53,7 @@ async def test_form_combined(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||
|
||||
|
||||
async def test_form_duplicates(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test abort on duplicate."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -122,7 +122,7 @@ async def test_wong_answer_from_device(hass: HomeAssistant) -> None:
|
||||
assert result2["data"] == {"host": "1.1.1.1"}
|
||||
|
||||
|
||||
async def test_dhcp_discovery(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
async def test_dhcp_discovery(hass: HomeAssistant) -> None:
|
||||
"""Test DHCP discovery shows a confirmation form and creates an entry."""
|
||||
with patch(
|
||||
"homeassistant.components.mystrom.config_flow.pymystrom.get_device_info",
|
||||
@@ -161,7 +161,6 @@ async def test_dhcp_discovery_cannot_connect(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_dhcp_discovery_already_configured_updates_host(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test DHCP discovery updates the host of an already-configured entry."""
|
||||
entry = MockConfigEntry(
|
||||
|
||||
@@ -42,11 +42,9 @@ async def test_full_flow(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_creating_route(
|
||||
hass: HomeAssistant,
|
||||
mock_nsapi: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_nsapi: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test creating a route after setting up the main config entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -125,11 +123,9 @@ async def test_flow_exceptions(
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_fetching_stations_failed(
|
||||
hass: HomeAssistant,
|
||||
mock_nsapi: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
hass: HomeAssistant, mock_nsapi: AsyncMock, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test creating a route after setting up the main config entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -55,8 +55,9 @@ async def test_user_flow(
|
||||
mock_client.close.assert_awaited_once()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_with_infer_arming_state(
|
||||
hass: HomeAssistant, mock_client: AsyncMock, mock_setup_entry: AsyncMock
|
||||
hass: HomeAssistant, mock_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test user flow with infer_arming_state enabled."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -107,10 +108,10 @@ async def test_user_flow_already_configured(
|
||||
(RuntimeError("Unexpected"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_user_flow_connection_error_recovery(
|
||||
hass: HomeAssistant,
|
||||
mock_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
@@ -202,10 +203,10 @@ async def test_import_yaml_config(
|
||||
(RuntimeError("Unexpected"), "unknown"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_import_yaml_config_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
side_effect: Exception,
|
||||
expected_reason: str,
|
||||
) -> None:
|
||||
|
||||
@@ -4,6 +4,7 @@ from types import MappingProxyType
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from nessclient import ArmingMode, ArmingState
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import alarm_control_panel
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
@@ -599,8 +600,9 @@ async def test_alarm_panel_home_mode_enabled_by_default(
|
||||
assert supported & AlarmControlPanelEntityFeature.TRIGGER
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_yaml_import_triggers_flow(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, issue_registry: ir.IssueRegistry
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test that YAML configuration triggers import flow."""
|
||||
with patch(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user