Add config flow to OpenSky (#96912)
Co-authored-by: Sander <developer@golles.nl>
This commit is contained in:
parent
b4200cb85e
commit
585d357129
15 changed files with 443 additions and 19 deletions
50
tests/components/opensky/conftest.py
Normal file
50
tests/components/opensky/conftest.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
"""Configure tests for the OpenSky integration."""
|
||||
from collections.abc import Awaitable, Callable
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from python_opensky import StatesResponse
|
||||
|
||||
from homeassistant.components.opensky.const import CONF_ALTITUDE, DOMAIN
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
ComponentSetup = Callable[[MockConfigEntry], Awaitable[None]]
|
||||
|
||||
|
||||
@pytest.fixture(name="config_entry")
|
||||
def mock_config_entry() -> MockConfigEntry:
|
||||
"""Create OpenSky entry in Home Assistant."""
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
title="OpenSky",
|
||||
data={
|
||||
CONF_LATITUDE: 0.0,
|
||||
CONF_LONGITUDE: 0.0,
|
||||
},
|
||||
options={
|
||||
CONF_RADIUS: 10.0,
|
||||
CONF_ALTITUDE: 0.0,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="setup_integration")
|
||||
async def mock_setup_integration(
|
||||
hass: HomeAssistant,
|
||||
) -> Callable[[MockConfigEntry], Awaitable[None]]:
|
||||
"""Fixture for setting up the component."""
|
||||
|
||||
async def func(mock_config_entry: MockConfigEntry) -> None:
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
with patch(
|
||||
"python_opensky.OpenSky.get_states",
|
||||
return_value=StatesResponse(states=[], time=0),
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
return func
|
Loading…
Add table
Add a link
Reference in a new issue