core/tests/components/ipma/conftest.py

43 lines
1.1 KiB
Python

"""Define test fixtures for IPMA."""
from unittest.mock import patch
import pytest
from homeassistant.components.ipma import DOMAIN
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
from . import MockLocation
from tests.common import MockConfigEntry
@pytest.fixture
def config_entry(hass: HomeAssistant) -> MockConfigEntry:
"""Define a config entry fixture."""
entry = MockConfigEntry(
domain=DOMAIN,
data={
CONF_NAME: "Home",
CONF_LATITUDE: 0,
CONF_LONGITUDE: 0,
},
)
entry.add_to_hass(hass)
return entry
@pytest.fixture
async def init_integration(
hass: HomeAssistant, config_entry: MockConfigEntry
) -> MockConfigEntry:
"""Set up the IPMA integration for testing."""
config_entry.add_to_hass(hass)
with patch("pyipma.location.Location.get", return_value=MockLocation()):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
return config_entry