* Add config_flow to frontier_silicon * Add missing translation file * Delay unique_id validation until radio_id can be determined * Fix tests * Improve tests * Use FlowResultType * Bump afsapi to 0.2.6 * Fix requirements_test_all.txt * Stash ssdp, reauth and unignore flows for now * Re-introduce SSDP flow * hassfest changes * Address review comments * Small style update * Fix tests * Update integrations.json * fix order in manifest.json * fix black errors * Apply suggestions from code review Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Address review comments * fix black errors * Use async_setup_platform instead of async_setup * Address review comments on tests * parameterize tests * Remove discovery component changes from this PR * Address review comments * Apply suggestions from code review Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Add extra asserts to tests * Restructure _async_step_device_config_if_needed * Add return statement * Update homeassistant/components/frontier_silicon/media_player.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> --------- Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
"""Configuration for frontier_silicon tests."""
|
|
from collections.abc import Generator
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components.frontier_silicon.const import (
|
|
CONF_PIN,
|
|
CONF_WEBFSAPI_URL,
|
|
DOMAIN,
|
|
)
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
@pytest.fixture
|
|
def config_entry() -> MockConfigEntry:
|
|
"""Create a mock Frontier Silicon config entry."""
|
|
return MockConfigEntry(
|
|
domain=DOMAIN,
|
|
unique_id="mock_radio_id",
|
|
data={CONF_WEBFSAPI_URL: "http://1.1.1.1:80/webfsapi", CONF_PIN: "1234"},
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def mock_valid_device_url() -> Generator[None, None, None]:
|
|
"""Return a valid webfsapi endpoint."""
|
|
with patch(
|
|
"afsapi.AFSAPI.get_webfsapi_endpoint",
|
|
return_value="http://1.1.1.1:80/webfsapi",
|
|
):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def mock_valid_pin() -> Generator[None, None, None]:
|
|
"""Make get_friendly_name return a value, indicating a valid pin."""
|
|
with patch(
|
|
"afsapi.AFSAPI.get_friendly_name",
|
|
return_value="Name of the device",
|
|
):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def mock_radio_id() -> Generator[None, None, None]:
|
|
"""Return a valid radio_id."""
|
|
with patch("afsapi.AFSAPI.get_radio_id", return_value="mock_radio_id"):
|
|
yield
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|
"""Override async_setup_entry."""
|
|
with patch(
|
|
"homeassistant.components.frontier_silicon.async_setup_entry", return_value=True
|
|
) as mock_setup_entry:
|
|
yield mock_setup_entry
|