1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-20 02:48:57 +00:00
Files
core/tests/components/amazon_devices/conftest.py
Simone Chemelli d0b2331a5f New integration Amazon Devices (#144422)
* New integration Amazon Devices

* apply review comments

* bump aioamazondevices

* Add notify platform

* pylance

* full coverage for coordinator tests

* cleanup imports

* Add switch platform

* update quality scale: docs items

* update quality scale: brands

* apply review comments

* fix new ruff rule

* simplify EntityDescription code

* remove additional platforms for first PR

* apply review comments

* update IQS

* apply last review comments

* snapshot update

* apply review comments

* apply review comments
2025-05-25 17:42:07 +02:00

77 lines
2.4 KiB
Python

"""Amazon Devices tests configuration."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch
from aioamazondevices.api import AmazonDevice
import pytest
from homeassistant.components.amazon_devices.const import CONF_LOGIN_DATA, DOMAIN
from homeassistant.const import CONF_COUNTRY, CONF_PASSWORD, CONF_USERNAME
from .const import TEST_COUNTRY, TEST_PASSWORD, TEST_SERIAL_NUMBER, TEST_USERNAME
from tests.common import MockConfigEntry
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.amazon_devices.async_setup_entry",
return_value=True,
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def mock_amazon_devices_client() -> Generator[AsyncMock]:
"""Mock an Amazon Devices client."""
with (
patch(
"homeassistant.components.amazon_devices.coordinator.AmazonEchoApi",
autospec=True,
) as mock_client,
patch(
"homeassistant.components.amazon_devices.config_flow.AmazonEchoApi",
new=mock_client,
),
):
client = mock_client.return_value
client.login_mode_interactive.return_value = {
"customer_info": {"user_id": TEST_USERNAME},
}
client.get_devices_data.return_value = {
TEST_SERIAL_NUMBER: AmazonDevice(
account_name="Echo Test",
capabilities=["AUDIO_PLAYER", "MICROPHONE"],
device_family="mine",
device_type="echo",
device_owner_customer_id="amazon_ower_id",
device_cluster_members=[TEST_SERIAL_NUMBER],
online=True,
serial_number=TEST_SERIAL_NUMBER,
software_version="echo_test_software_version",
do_not_disturb=False,
response_style=None,
bluetooth_state=True,
)
}
yield client
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Mock a config entry."""
return MockConfigEntry(
domain=DOMAIN,
title="Amazon Test Account",
data={
CONF_COUNTRY: TEST_COUNTRY,
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
CONF_LOGIN_DATA: {"session": "test-session"},
},
unique_id=TEST_USERNAME,
)