mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Move current_request_with_host fixture to decorator (#118810)
* Move current_request_with_host fixture to decorator * One more
This commit is contained in:
parent
52ad90a68d
commit
b81f0b600f
@ -80,11 +80,11 @@ async def _oauth_actions(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -105,11 +105,11 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_duplicate_entry(
|
async def test_duplicate_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -125,11 +125,11 @@ async def test_duplicate_entry(
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
@ -154,11 +154,11 @@ async def test_reauth(
|
|||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_wrong_account(
|
async def test_reauth_wrong_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -189,11 +189,11 @@ async def test_reauth_wrong_account(
|
|||||||
assert result["reason"] == "wrong_account"
|
assert result["reason"] == "wrong_account"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_old_account(
|
async def test_reauth_old_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -178,9 +178,8 @@ async def test_get_services_error(hass: HomeAssistant) -> None:
|
|||||||
assert account_link.DATA_SERVICES not in hass.data
|
assert account_link.DATA_SERVICES not in hass.data
|
||||||
|
|
||||||
|
|
||||||
async def test_implementation(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, flow_handler, current_request_with_host: None
|
async def test_implementation(hass: HomeAssistant, flow_handler) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test Cloud OAuth2 implementation."""
|
"""Test Cloud OAuth2 implementation."""
|
||||||
hass.data["cloud"] = None
|
hass.data["cloud"] = None
|
||||||
|
|
||||||
|
@ -53,11 +53,11 @@ async def test_config_flow_no_credentials(hass: HomeAssistant) -> None:
|
|||||||
assert result.get("reason") == "missing_credentials"
|
assert result.get("reason") == "missing_credentials"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -107,11 +107,11 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_existing_entry(
|
async def test_existing_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -150,10 +150,10 @@ async def test_existing_entry(
|
|||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauthentication(
|
async def test_reauthentication(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_setup_entry: MagicMock,
|
mock_setup_entry: MagicMock,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
|
@ -32,11 +32,11 @@ from tests.typing import ClientSessionGenerator
|
|||||||
REDIRECT_URL = "https://example.com/auth/external/callback"
|
REDIRECT_URL = "https://example.com/auth/external/callback"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
profile: None,
|
profile: None,
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -97,11 +97,11 @@ async def test_full_flow(
|
|||||||
(HTTPStatus.INTERNAL_SERVER_ERROR, "cannot_connect"),
|
(HTTPStatus.INTERNAL_SERVER_ERROR, "cannot_connect"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_token_error(
|
async def test_token_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
profile: None,
|
profile: None,
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
status_code: HTTPStatus,
|
status_code: HTTPStatus,
|
||||||
@ -155,11 +155,11 @@ async def test_token_error(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_api_failure(
|
async def test_api_failure(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
requests_mock: Mocker,
|
requests_mock: Mocker,
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
http_status: HTTPStatus,
|
http_status: HTTPStatus,
|
||||||
@ -207,12 +207,11 @@ async def test_api_failure(
|
|||||||
assert result.get("reason") == error_reason
|
assert result.get("reason") == error_reason
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_entry_already_exists(
|
async def test_config_entry_already_exists(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
requests_mock: Mocker,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
integration_setup: Callable[[], Awaitable[bool]],
|
integration_setup: Callable[[], Awaitable[bool]],
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
@ -457,12 +456,12 @@ async def test_platform_setup_without_import(
|
|||||||
assert issue.translation_key == "deprecated_yaml_no_import"
|
assert issue.translation_key == "deprecated_yaml_no_import"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_flow(
|
async def test_reauth_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
profile: None,
|
profile: None,
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -532,12 +531,12 @@ async def test_reauth_flow(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("profile_id", ["other-user-id"])
|
@pytest.mark.parametrize("profile_id", ["other-user-id"])
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_wrong_user_id(
|
async def test_reauth_wrong_user_id(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
profile: None,
|
profile: None,
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -610,11 +609,11 @@ async def test_reauth_wrong_user_id(
|
|||||||
],
|
],
|
||||||
ids=("full_profile_data", "display_name_only"),
|
ids=("full_profile_data", "display_name_only"),
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_partial_profile_data(
|
async def test_partial_profile_data(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
profile: None,
|
profile: None,
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
expected_title: str,
|
expected_title: str,
|
||||||
|
@ -40,11 +40,11 @@ async def setup_credentials(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_geocaching_config_flow: MagicMock,
|
mock_geocaching_config_flow: MagicMock,
|
||||||
mock_setup_entry: MagicMock,
|
mock_setup_entry: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -90,11 +90,11 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_existing_entry(
|
async def test_existing_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_geocaching_config_flow: MagicMock,
|
mock_geocaching_config_flow: MagicMock,
|
||||||
mock_setup_entry: MagicMock,
|
mock_setup_entry: MagicMock,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
@ -136,11 +136,11 @@ async def test_existing_entry(
|
|||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_oauth_error(
|
async def test_oauth_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_geocaching_config_flow: MagicMock,
|
mock_geocaching_config_flow: MagicMock,
|
||||||
mock_setup_entry: MagicMock,
|
mock_setup_entry: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -183,11 +183,11 @@ async def test_oauth_error(
|
|||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauthentication(
|
async def test_reauthentication(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_geocaching_config_flow: MagicMock,
|
mock_geocaching_config_flow: MagicMock,
|
||||||
mock_setup_entry: MagicMock,
|
mock_setup_entry: MagicMock,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
|
@ -656,9 +656,9 @@ async def test_options_flow_no_changes(
|
|||||||
assert config_entry.options == {"calendar_access": "read_write"}
|
assert config_entry.options == {"calendar_access": "read_write"}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_web_auth_compatibility(
|
async def test_web_auth_compatibility(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_code_flow: Mock,
|
mock_code_flow: Mock,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.google_assistant_sdk.const import DOMAIN
|
from homeassistant.components.google_assistant_sdk.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -19,11 +21,11 @@ GOOGLE_TOKEN_URI = "https://oauth2.googleapis.com/token"
|
|||||||
TITLE = "Google Assistant SDK"
|
TITLE = "Google Assistant SDK"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
@ -80,11 +82,11 @@ async def test_full_flow(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the reauthentication case updates the existing config entry."""
|
"""Test the reauthentication case updates the existing config entry."""
|
||||||
@ -155,11 +157,11 @@ async def test_reauth(
|
|||||||
assert config_entry.data["token"].get("refresh_token") == "mock-refresh-token"
|
assert config_entry.data["token"].get("refresh_token") == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_single_instance_allowed(
|
async def test_single_instance_allowed(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test case where config flow allows a single test."""
|
"""Test case where config flow allows a single test."""
|
||||||
|
@ -18,10 +18,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -88,11 +87,11 @@ async def test_full_flow(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
fixture: str,
|
fixture: str,
|
||||||
abort_reason: str,
|
abort_reason: str,
|
||||||
@ -173,10 +172,10 @@ async def test_reauth(
|
|||||||
assert config_entry.data["token"].get("refresh_token") == "mock-refresh-token"
|
assert config_entry.data["token"].get("refresh_token") == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_already_configured(
|
async def test_already_configured(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test case where config flow discovers unique id was already configured."""
|
"""Test case where config flow discovers unique id was already configured."""
|
||||||
|
@ -49,11 +49,11 @@ async def mock_client() -> Generator[Mock, None, None]:
|
|||||||
yield mock_client
|
yield mock_client
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
mock_client,
|
mock_client,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -116,11 +116,11 @@ async def test_full_flow(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_create_sheet_error(
|
async def test_create_sheet_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
mock_client,
|
mock_client,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -168,11 +168,11 @@ async def test_create_sheet_error(
|
|||||||
assert result.get("reason") == "create_spreadsheet_failure"
|
assert result.get("reason") == "create_spreadsheet_failure"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
mock_client,
|
mock_client,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -249,11 +249,11 @@ async def test_reauth(
|
|||||||
assert config_entry.data["token"].get("refresh_token") == "mock-refresh-token"
|
assert config_entry.data["token"].get("refresh_token") == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_abort(
|
async def test_reauth_abort(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
mock_client,
|
mock_client,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -318,11 +318,11 @@ async def test_reauth_abort(
|
|||||||
assert result.get("reason") == "open_spreadsheet_failure"
|
assert result.get("reason") == "open_spreadsheet_failure"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_already_configured(
|
async def test_already_configured(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
mock_client,
|
mock_client,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -42,11 +42,11 @@ def setup_userinfo(user_identifier: str) -> Generator[Mock, None, None]:
|
|||||||
yield mock
|
yield mock
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
setup_userinfo,
|
setup_userinfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -97,11 +97,11 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_api_not_enabled(
|
async def test_api_not_enabled(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
setup_userinfo,
|
setup_userinfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -158,11 +158,11 @@ async def test_api_not_enabled(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_general_exception(
|
async def test_general_exception(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
setup_userinfo,
|
setup_userinfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -235,11 +235,11 @@ async def test_general_exception(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
setup_userinfo,
|
setup_userinfo,
|
||||||
user_identifier: str,
|
user_identifier: str,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
ClientCredential,
|
ClientCredential,
|
||||||
@ -24,11 +26,11 @@ CLIENT_ID = "1234"
|
|||||||
CLIENT_SECRET = "5678"
|
CLIENT_SECRET = "5678"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(hass, "home_connect", {})
|
assert await setup.async_setup_component(hass, "home_connect", {})
|
||||||
|
@ -30,11 +30,11 @@ from tests.typing import ClientSessionGenerator
|
|||||||
("iam:read", 0),
|
("iam:read", 0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
jwt: str,
|
jwt: str,
|
||||||
new_scope: str,
|
new_scope: str,
|
||||||
amount: int,
|
amount: int,
|
||||||
@ -87,10 +87,10 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup.mock_calls) == amount
|
assert len(mock_setup.mock_calls) == amount
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_non_unique_profile(
|
async def test_config_non_unique_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_automower_client: AsyncMock,
|
mock_automower_client: AsyncMock,
|
||||||
@ -148,12 +148,12 @@ async def test_config_non_unique_profile(
|
|||||||
("iam:read", "missing_scope", "missing_amc_scope", "iam:read"),
|
("iam:read", "missing_scope", "missing_amc_scope", "iam:read"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_automower_client: AsyncMock,
|
mock_automower_client: AsyncMock,
|
||||||
jwt: str,
|
jwt: str,
|
||||||
step_id: str,
|
step_id: str,
|
||||||
@ -228,12 +228,12 @@ async def test_reauth(
|
|||||||
("wrong_user_id", "wrong_account"),
|
("wrong_user_id", "wrong_account"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_wrong_account(
|
async def test_reauth_wrong_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_automower_client: AsyncMock,
|
mock_automower_client: AsyncMock,
|
||||||
jwt,
|
jwt,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
@ -45,11 +45,11 @@ async def test_abort_if_no_configuration(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "missing_credentials"
|
assert result["reason"] == "missing_credentials"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_impl,
|
mock_impl,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
@ -112,11 +112,11 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauthentication_flow(
|
async def test_reauthentication_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_impl,
|
mock_impl,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauthentication flow."""
|
"""Test reauthentication flow."""
|
||||||
|
@ -19,10 +19,10 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
microbees: AsyncMock,
|
microbees: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -80,10 +80,10 @@ async def test_full_flow(
|
|||||||
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"
|
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_non_unique_profile(
|
async def test_config_non_unique_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
microbees: AsyncMock,
|
microbees: AsyncMock,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
@ -133,13 +133,13 @@ async def test_config_non_unique_profile(
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_reauth_profile(
|
async def test_config_reauth_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
microbees: AsyncMock,
|
microbees: AsyncMock,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth an existing profile reauthenticates the config entry."""
|
"""Test reauth an existing profile reauthenticates the config entry."""
|
||||||
await setup_integration(hass, config_entry)
|
await setup_integration(hass, config_entry)
|
||||||
@ -194,13 +194,13 @@ async def test_config_reauth_profile(
|
|||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_reauth_wrong_account(
|
async def test_config_reauth_wrong_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
microbees: AsyncMock,
|
microbees: AsyncMock,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth with wrong account."""
|
"""Test reauth with wrong account."""
|
||||||
await setup_integration(hass, config_entry)
|
await setup_integration(hass, config_entry)
|
||||||
@ -255,12 +255,12 @@ async def test_config_reauth_wrong_account(
|
|||||||
assert result["reason"] == "wrong_account"
|
assert result["reason"] == "wrong_account"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_flow_with_invalid_credentials(
|
async def test_config_flow_with_invalid_credentials(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
microbees: AsyncMock,
|
microbees: AsyncMock,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test flow with invalid credentials."""
|
"""Test flow with invalid credentials."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -310,6 +310,7 @@ async def test_config_flow_with_invalid_credentials(
|
|||||||
(Exception("Unexpected error"), "unknown"),
|
(Exception("Unexpected error"), "unknown"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_unexpected_exceptions(
|
async def test_unexpected_exceptions(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
@ -318,7 +319,6 @@ async def test_unexpected_exceptions(
|
|||||||
microbees: AsyncMock,
|
microbees: AsyncMock,
|
||||||
exception: Exception,
|
exception: Exception,
|
||||||
error: str,
|
error: str,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test unknown error from server."""
|
"""Test unknown error from server."""
|
||||||
await setup_integration(hass, config_entry)
|
await setup_integration(hass, config_entry)
|
||||||
|
@ -5,6 +5,7 @@ from unittest.mock import AsyncMock, patch
|
|||||||
|
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
from monzopy import AuthorisationExpiredError
|
from monzopy import AuthorisationExpiredError
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.monzo.application_credentials import (
|
from homeassistant.components.monzo.application_credentials import (
|
||||||
OAUTH2_AUTHORIZE,
|
OAUTH2_AUTHORIZE,
|
||||||
@ -24,10 +25,10 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
@ -92,10 +93,10 @@ async def test_full_flow(
|
|||||||
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"
|
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_non_unique_profile(
|
async def test_config_non_unique_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
monzo: AsyncMock,
|
monzo: AsyncMock,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
@ -142,13 +143,13 @@ async def test_config_non_unique_profile(
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_reauth_profile(
|
async def test_config_reauth_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
monzo: AsyncMock,
|
monzo: AsyncMock,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth an existing profile reauthenticates the config entry."""
|
"""Test reauth an existing profile reauthenticates the config entry."""
|
||||||
await setup_integration(hass, polling_config_entry)
|
await setup_integration(hass, polling_config_entry)
|
||||||
@ -212,12 +213,12 @@ async def test_config_reauth_profile(
|
|||||||
assert polling_config_entry.data["token"]["access_token"] == "new-mock-access-token"
|
assert polling_config_entry.data["token"]["access_token"] == "new-mock-access-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_reauth_wrong_account(
|
async def test_config_reauth_wrong_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth with wrong account."""
|
"""Test reauth with wrong account."""
|
||||||
await setup_integration(hass, polling_config_entry)
|
await setup_integration(hass, polling_config_entry)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.myuplink.const import (
|
from homeassistant.components.myuplink.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -22,11 +24,11 @@ REDIRECT_URL = "https://example.com/auth/external/callback"
|
|||||||
CURRENT_SCOPE = "WRITESYSTEM READSYSTEM offline_access"
|
CURRENT_SCOPE = "WRITESYSTEM READSYSTEM offline_access"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials,
|
setup_credentials,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
@ -72,11 +74,11 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_flow_reauth(
|
async def test_flow_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
setup_credentials: None,
|
setup_credentials: None,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
expires_at: float,
|
expires_at: float,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pybotvac.neato import Neato
|
from pybotvac.neato import Neato
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
@ -27,11 +28,11 @@ OAUTH2_AUTHORIZE = VENDOR.auth_endpoint
|
|||||||
OAUTH2_TOKEN = VENDOR.token_endpoint
|
OAUTH2_TOKEN = VENDOR.token_endpoint
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(hass, "neato", {})
|
assert await setup.async_setup_component(hass, "neato", {})
|
||||||
@ -98,11 +99,11 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test initialization of the reauth flow."""
|
"""Test initialization of the reauth flow."""
|
||||||
assert await setup.async_setup_component(hass, "neato", {})
|
assert await setup.async_setup_component(hass, "neato", {})
|
||||||
|
@ -4,6 +4,7 @@ from ipaddress import ip_address
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pyatmo.const import ALL_SCOPES
|
from pyatmo.const import ALL_SCOPES
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
@ -59,11 +60,11 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
|
|
||||||
@ -226,11 +227,11 @@ async def test_option_flow_wrong_coordinates(hass: HomeAssistant) -> None:
|
|||||||
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test initialization of the reauth flow."""
|
"""Test initialization of the reauth flow."""
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.ondilo_ico.const import (
|
from homeassistant.components.ondilo_ico.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -34,11 +36,11 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(
|
assert await setup.async_setup_component(
|
||||||
|
@ -49,9 +49,8 @@ from tests.common import MockConfigEntry
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
async def test_bad_credentials(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, current_request_with_host: None
|
async def test_bad_credentials(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test when provided credentials are rejected."""
|
"""Test when provided credentials are rejected."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
@ -81,9 +80,8 @@ async def test_bad_credentials(
|
|||||||
assert result["errors"][CONF_TOKEN] == "faulty_credentials"
|
assert result["errors"][CONF_TOKEN] == "faulty_credentials"
|
||||||
|
|
||||||
|
|
||||||
async def test_bad_hostname(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, mock_plex_calls, current_request_with_host: None
|
async def test_bad_hostname(hass: HomeAssistant, mock_plex_calls) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test when an invalid address is provided."""
|
"""Test when an invalid address is provided."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
@ -114,9 +112,8 @@ async def test_bad_hostname(
|
|||||||
assert result["errors"][CONF_HOST] == "not_found"
|
assert result["errors"][CONF_HOST] == "not_found"
|
||||||
|
|
||||||
|
|
||||||
async def test_unknown_exception(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, current_request_with_host: None
|
async def test_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test when an unknown exception is encountered."""
|
"""Test when an unknown exception is encountered."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
@ -142,12 +139,12 @@ async def test_unknown_exception(
|
|||||||
assert result["reason"] == "unknown"
|
assert result["reason"] == "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_no_servers_found(
|
async def test_no_servers_found(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_plex_calls,
|
mock_plex_calls,
|
||||||
requests_mock: requests_mock.Mocker,
|
requests_mock: requests_mock.Mocker,
|
||||||
empty_payload,
|
empty_payload,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test when no servers are on an account."""
|
"""Test when no servers are on an account."""
|
||||||
requests_mock.get("https://plex.tv/api/v2/resources", text=empty_payload)
|
requests_mock.get("https://plex.tv/api/v2/resources", text=empty_payload)
|
||||||
@ -176,10 +173,10 @@ async def test_no_servers_found(
|
|||||||
assert result["errors"]["base"] == "no_servers"
|
assert result["errors"]["base"] == "no_servers"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_single_available_server(
|
async def test_single_available_server(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_plex_calls,
|
mock_plex_calls,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test creating an entry with one server available."""
|
"""Test creating an entry with one server available."""
|
||||||
@ -218,12 +215,12 @@ async def test_single_available_server(
|
|||||||
mock_setup_entry.assert_called_once()
|
mock_setup_entry.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_multiple_servers_with_selection(
|
async def test_multiple_servers_with_selection(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_plex_calls,
|
mock_plex_calls,
|
||||||
requests_mock: requests_mock.Mocker,
|
requests_mock: requests_mock.Mocker,
|
||||||
plextv_resources_two_servers,
|
plextv_resources_two_servers,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test creating an entry with multiple servers available."""
|
"""Test creating an entry with multiple servers available."""
|
||||||
@ -275,12 +272,12 @@ async def test_multiple_servers_with_selection(
|
|||||||
mock_setup_entry.assert_called_once()
|
mock_setup_entry.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_adding_last_unconfigured_server(
|
async def test_adding_last_unconfigured_server(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_plex_calls,
|
mock_plex_calls,
|
||||||
requests_mock: requests_mock.Mocker,
|
requests_mock: requests_mock.Mocker,
|
||||||
plextv_resources_two_servers,
|
plextv_resources_two_servers,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test automatically adding last unconfigured server when multiple servers on account."""
|
"""Test automatically adding last unconfigured server when multiple servers on account."""
|
||||||
@ -332,13 +329,13 @@ async def test_adding_last_unconfigured_server(
|
|||||||
assert mock_setup_entry.call_count == 2
|
assert mock_setup_entry.call_count == 2
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_all_available_servers_configured(
|
async def test_all_available_servers_configured(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry,
|
entry,
|
||||||
requests_mock: requests_mock.Mocker,
|
requests_mock: requests_mock.Mocker,
|
||||||
plextv_account,
|
plextv_account,
|
||||||
plextv_resources_two_servers,
|
plextv_resources_two_servers,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test when all available servers are already configured."""
|
"""Test when all available servers are already configured."""
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
@ -479,9 +476,8 @@ async def test_option_flow_new_users_available(
|
|||||||
assert "[New]" in multiselect_defaults[user]
|
assert "[New]" in multiselect_defaults[user]
|
||||||
|
|
||||||
|
|
||||||
async def test_external_timed_out(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, current_request_with_host: None
|
async def test_external_timed_out(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test when external flow times out."""
|
"""Test when external flow times out."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
@ -506,10 +502,10 @@ async def test_external_timed_out(
|
|||||||
assert result["reason"] == "token_request_timeout"
|
assert result["reason"] == "token_request_timeout"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_callback_view(
|
async def test_callback_view(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test callback view."""
|
"""Test callback view."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -534,9 +530,8 @@ async def test_callback_view(
|
|||||||
assert resp.status == HTTPStatus.OK
|
assert resp.status == HTTPStatus.OK
|
||||||
|
|
||||||
|
|
||||||
async def test_manual_config(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, mock_plex_calls, current_request_with_host: None
|
async def test_manual_config(hass: HomeAssistant, mock_plex_calls) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test creating via manual configuration."""
|
"""Test creating via manual configuration."""
|
||||||
|
|
||||||
class WrongCertValidaitionException(requests.exceptions.SSLError):
|
class WrongCertValidaitionException(requests.exceptions.SSLError):
|
||||||
@ -739,11 +734,11 @@ async def test_integration_discovery(hass: HomeAssistant) -> None:
|
|||||||
assert flow["step_id"] == "user"
|
assert flow["step_id"] == "user"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: MockConfigEntry,
|
entry: MockConfigEntry,
|
||||||
mock_plex_calls: None,
|
mock_plex_calls: None,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setup and reauthorization of a Plex token."""
|
"""Test setup and reauthorization of a Plex token."""
|
||||||
@ -783,11 +778,11 @@ async def test_reauth(
|
|||||||
mock_setup_entry.assert_called_once()
|
mock_setup_entry.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_multiple_servers_available(
|
async def test_reauth_multiple_servers_available(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: MockConfigEntry,
|
entry: MockConfigEntry,
|
||||||
mock_plex_calls: None,
|
mock_plex_calls: None,
|
||||||
current_request_with_host: None,
|
|
||||||
requests_mock: requests_mock.Mocker,
|
requests_mock: requests_mock.Mocker,
|
||||||
plextv_resources_two_servers: str,
|
plextv_resources_two_servers: str,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
@ -853,9 +848,8 @@ async def test_client_request_missing(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_client_header_issues(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, current_request_with_host: None
|
async def test_client_header_issues(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test when client headers are not set properly."""
|
"""Test when client headers are not set properly."""
|
||||||
|
|
||||||
class MockRequest:
|
class MockRequest:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from aiosenz import AUTHORIZATION_ENDPOINT, TOKEN_ENDPOINT
|
from aiosenz import AUTHORIZATION_ENDPOINT, TOKEN_ENDPOINT
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
@ -21,11 +22,11 @@ CLIENT_ID = "1234"
|
|||||||
CLIENT_SECRET = "5678"
|
CLIENT_SECRET = "5678"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
await async_setup_component(hass, DOMAIN, {})
|
await async_setup_component(hass, DOMAIN, {})
|
||||||
|
@ -4,6 +4,8 @@ from http import HTTPStatus
|
|||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import setup
|
from homeassistant import setup
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.smappee.const import (
|
from homeassistant.components.smappee.const import (
|
||||||
@ -427,11 +429,11 @@ async def test_abort_cloud_flow_if_local_device_exists(hass: HomeAssistant) -> N
|
|||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_user_flow(
|
async def test_full_user_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(
|
assert await setup.async_setup_component(
|
||||||
|
@ -76,12 +76,12 @@ async def test_zeroconf_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
component_setup,
|
component_setup,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check a full flow."""
|
"""Check a full flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -143,12 +143,12 @@ async def test_full_flow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_abort_if_spotify_error(
|
async def test_abort_if_spotify_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
component_setup,
|
component_setup,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check Spotify errors causes flow to abort."""
|
"""Check Spotify errors causes flow to abort."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -185,12 +185,12 @@ async def test_abort_if_spotify_error(
|
|||||||
assert result["reason"] == "connection_error"
|
assert result["reason"] == "connection_error"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauthentication(
|
async def test_reauthentication(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
component_setup,
|
component_setup,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test Spotify reauthentication."""
|
"""Test Spotify reauthentication."""
|
||||||
old_entry = MockConfigEntry(
|
old_entry = MockConfigEntry(
|
||||||
@ -253,12 +253,12 @@ async def test_reauthentication(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_account_mismatch(
|
async def test_reauth_account_mismatch(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
component_setup,
|
component_setup,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test Spotify reauthentication with different account."""
|
"""Test Spotify reauthentication with different account."""
|
||||||
old_entry = MockConfigEntry(
|
old_entry = MockConfigEntry(
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
from toonapi import Agreement, ToonError
|
from toonapi import Agreement, ToonError
|
||||||
|
|
||||||
from homeassistant.components.toon.const import CONF_AGREEMENT, CONF_MIGRATE, DOMAIN
|
from homeassistant.components.toon.const import CONF_AGREEMENT, CONF_MIGRATE, DOMAIN
|
||||||
@ -45,11 +46,11 @@ async def test_abort_if_no_configuration(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "missing_configuration"
|
assert result["reason"] == "missing_configuration"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow_implementation(
|
async def test_full_flow_implementation(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test registering an integration and finishing flow works."""
|
"""Test registering an integration and finishing flow works."""
|
||||||
await setup_component(hass)
|
await setup_component(hass)
|
||||||
@ -111,11 +112,11 @@ async def test_full_flow_implementation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_no_agreements(
|
async def test_no_agreements(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test abort when there are no displays."""
|
"""Test abort when there are no displays."""
|
||||||
await setup_component(hass)
|
await setup_component(hass)
|
||||||
@ -153,11 +154,11 @@ async def test_no_agreements(
|
|||||||
assert result3["reason"] == "no_agreements"
|
assert result3["reason"] == "no_agreements"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_multiple_agreements(
|
async def test_multiple_agreements(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test abort when there are no displays."""
|
"""Test abort when there are no displays."""
|
||||||
await setup_component(hass)
|
await setup_component(hass)
|
||||||
@ -205,11 +206,11 @@ async def test_multiple_agreements(
|
|||||||
assert result4["data"]["agreement_id"] == 1
|
assert result4["data"]["agreement_id"] == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_agreement_already_set_up(
|
async def test_agreement_already_set_up(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test showing display form again if display already exists."""
|
"""Test showing display form again if display already exists."""
|
||||||
await setup_component(hass)
|
await setup_component(hass)
|
||||||
@ -248,11 +249,11 @@ async def test_agreement_already_set_up(
|
|||||||
assert result3["reason"] == "already_configured"
|
assert result3["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_toon_abort(
|
async def test_toon_abort(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we abort on Toon error."""
|
"""Test we abort on Toon error."""
|
||||||
await setup_component(hass)
|
await setup_component(hass)
|
||||||
@ -290,7 +291,8 @@ async def test_toon_abort(
|
|||||||
assert result2["reason"] == "connection_error"
|
assert result2["reason"] == "connection_error"
|
||||||
|
|
||||||
|
|
||||||
async def test_import(hass: HomeAssistant, current_request_with_host: None) -> None:
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
|
async def test_import(hass: HomeAssistant) -> None:
|
||||||
"""Test if importing step works."""
|
"""Test if importing step works."""
|
||||||
await setup_component(hass)
|
await setup_component(hass)
|
||||||
|
|
||||||
@ -304,11 +306,11 @@ async def test_import(hass: HomeAssistant, current_request_with_host: None) -> N
|
|||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_import_migration(
|
async def test_import_migration(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test if importing step with migration works."""
|
"""Test if importing step with migration works."""
|
||||||
old_entry = MockConfigEntry(domain=DOMAIN, unique_id=123, version=1)
|
old_entry = MockConfigEntry(domain=DOMAIN, unique_id=123, version=1)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
|
import pytest
|
||||||
from twitchAPI.object.api import TwitchUser
|
from twitchAPI.object.api import TwitchUser
|
||||||
|
|
||||||
from homeassistant.components.twitch.const import (
|
from homeassistant.components.twitch.const import (
|
||||||
@ -47,10 +48,10 @@ async def _do_get_token(
|
|||||||
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_setup_entry,
|
mock_setup_entry,
|
||||||
twitch_mock: AsyncMock,
|
twitch_mock: AsyncMock,
|
||||||
scopes: list[str],
|
scopes: list[str],
|
||||||
@ -75,10 +76,10 @@ async def test_full_flow(
|
|||||||
assert result["options"] == {CONF_CHANNELS: ["internetofthings", "homeassistant"]}
|
assert result["options"] == {CONF_CHANNELS: ["internetofthings", "homeassistant"]}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_already_configured(
|
async def test_already_configured(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
mock_setup_entry,
|
mock_setup_entry,
|
||||||
twitch_mock: AsyncMock,
|
twitch_mock: AsyncMock,
|
||||||
@ -97,10 +98,10 @@ async def test_already_configured(
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
mock_setup_entry,
|
mock_setup_entry,
|
||||||
twitch_mock: AsyncMock,
|
twitch_mock: AsyncMock,
|
||||||
@ -129,10 +130,10 @@ async def test_reauth(
|
|||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_from_import(
|
async def test_reauth_from_import(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
mock_setup_entry,
|
mock_setup_entry,
|
||||||
twitch_mock: AsyncMock,
|
twitch_mock: AsyncMock,
|
||||||
expires_at,
|
expires_at,
|
||||||
@ -158,7 +159,6 @@ async def test_reauth_from_import(
|
|||||||
await test_reauth(
|
await test_reauth(
|
||||||
hass,
|
hass,
|
||||||
hass_client_no_auth,
|
hass_client_no_auth,
|
||||||
current_request_with_host,
|
|
||||||
config_entry,
|
config_entry,
|
||||||
mock_setup_entry,
|
mock_setup_entry,
|
||||||
twitch_mock,
|
twitch_mock,
|
||||||
@ -170,10 +170,10 @@ async def test_reauth_from_import(
|
|||||||
assert entry.options == {CONF_CHANNELS: ["internetofthings", "homeassistant"]}
|
assert entry.options == {CONF_CHANNELS: ["internetofthings", "homeassistant"]}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth_wrong_account(
|
async def test_reauth_wrong_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
mock_setup_entry,
|
mock_setup_entry,
|
||||||
twitch_mock: AsyncMock,
|
twitch_mock: AsyncMock,
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.withings.const import DOMAIN
|
from homeassistant.components.withings.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -16,10 +18,10 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
@ -79,10 +81,10 @@ async def test_full_flow(
|
|||||||
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"
|
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_non_unique_profile(
|
async def test_config_non_unique_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
withings: AsyncMock,
|
withings: AsyncMock,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
@ -132,13 +134,13 @@ async def test_config_non_unique_profile(
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_reauth_profile(
|
async def test_config_reauth_profile(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
withings: AsyncMock,
|
withings: AsyncMock,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth an existing profile reauthenticates the config entry."""
|
"""Test reauth an existing profile reauthenticates the config entry."""
|
||||||
await setup_integration(hass, polling_config_entry)
|
await setup_integration(hass, polling_config_entry)
|
||||||
@ -194,13 +196,13 @@ async def test_config_reauth_profile(
|
|||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_reauth_wrong_account(
|
async def test_config_reauth_wrong_account(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
withings: AsyncMock,
|
withings: AsyncMock,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth with wrong account."""
|
"""Test reauth with wrong account."""
|
||||||
await setup_integration(hass, polling_config_entry)
|
await setup_integration(hass, polling_config_entry)
|
||||||
@ -256,13 +258,13 @@ async def test_config_reauth_wrong_account(
|
|||||||
assert result["reason"] == "wrong_account"
|
assert result["reason"] == "wrong_account"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_config_flow_with_invalid_credentials(
|
async def test_config_flow_with_invalid_credentials(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
polling_config_entry: MockConfigEntry,
|
polling_config_entry: MockConfigEntry,
|
||||||
withings: AsyncMock,
|
withings: AsyncMock,
|
||||||
current_request_with_host,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test flow with invalid credentials."""
|
"""Test flow with invalid credentials."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -544,6 +544,7 @@ async def test_cloud_disconnect_retry(
|
|||||||
), # Success, we ignore the user_id
|
), # Success, we ignore the user_id
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_webhook_post(
|
async def test_webhook_post(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
withings: AsyncMock,
|
withings: AsyncMock,
|
||||||
@ -551,7 +552,6 @@ async def test_webhook_post(
|
|||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
body: dict[str, Any],
|
body: dict[str, Any],
|
||||||
expected_code: int,
|
expected_code: int,
|
||||||
current_request_with_host: None,
|
|
||||||
freezer: FrozenDateTimeFactory,
|
freezer: FrozenDateTimeFactory,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test webhook callback."""
|
"""Test webhook callback."""
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
ClientCredential,
|
ClientCredential,
|
||||||
@ -32,11 +34,11 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(hass, "application_credentials", {})
|
assert await setup.async_setup_component(hass, "application_credentials", {})
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
from yolink.const import OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
from yolink.const import OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
@ -40,11 +41,11 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(
|
assert await setup.async_setup_component(
|
||||||
@ -115,9 +116,8 @@ async def test_full_flow(
|
|||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_abort_if_authorization_timeout(
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
hass: HomeAssistant, current_request_with_host: None
|
async def test_abort_if_authorization_timeout(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Check yolink authorization timeout."""
|
"""Check yolink authorization timeout."""
|
||||||
assert await setup.async_setup_component(
|
assert await setup.async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
@ -142,11 +142,11 @@ async def test_abort_if_authorization_timeout(
|
|||||||
assert result["reason"] == "authorize_url_timeout"
|
assert result["reason"] == "authorize_url_timeout"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauthentication(
|
async def test_reauthentication(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test yolink reauthentication."""
|
"""Test yolink reauthentication."""
|
||||||
await setup.async_setup_component(
|
await setup.async_setup_component(
|
||||||
|
@ -26,10 +26,10 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_full_flow(
|
async def test_full_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -85,10 +85,10 @@ async def test_full_flow(
|
|||||||
assert result["options"] == {CONF_CHANNELS: ["UC_x5XG1OV2P6uZZ5FSM9Ttw"]}
|
assert result["options"] == {CONF_CHANNELS: ["UC_x5XG1OV2P6uZZ5FSM9Ttw"]}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_flow_abort_without_channel(
|
async def test_flow_abort_without_channel(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check abort flow if user has no channel."""
|
"""Check abort flow if user has no channel."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -126,10 +126,10 @@ async def test_flow_abort_without_channel(
|
|||||||
assert result["reason"] == "no_channel"
|
assert result["reason"] == "no_channel"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_flow_abort_without_subscriptions(
|
async def test_flow_abort_without_subscriptions(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check abort flow if user has no subscriptions."""
|
"""Check abort flow if user has no subscriptions."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -167,10 +167,10 @@ async def test_flow_abort_without_subscriptions(
|
|||||||
assert result["reason"] == "no_subscriptions"
|
assert result["reason"] == "no_subscriptions"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_flow_http_error(
|
async def test_flow_http_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -229,11 +229,11 @@ async def test_flow_http_error(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
current_request_with_host: None,
|
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
fixture: str,
|
fixture: str,
|
||||||
abort_reason: str,
|
abort_reason: str,
|
||||||
@ -312,10 +312,10 @@ async def test_reauth(
|
|||||||
assert config_entry.data["token"]["refresh_token"] == "mock-refresh-token"
|
assert config_entry.data["token"]["refresh_token"] == "mock-refresh-token"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("current_request_with_host")
|
||||||
async def test_flow_exception(
|
async def test_flow_exception(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
current_request_with_host: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user