2022-01-24 14:51:30 +00:00
|
|
|
"""Define test fixtures for ReCollect Waste."""
|
2022-01-24 15:18:22 +00:00
|
|
|
from datetime import date
|
2022-01-24 14:51:30 +00:00
|
|
|
from unittest.mock import patch
|
|
|
|
|
2022-01-24 15:18:22 +00:00
|
|
|
from aiorecollect.client import PickupEvent, PickupType
|
2022-01-24 14:51:30 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from homeassistant.components.recollect_waste.const import (
|
|
|
|
CONF_PLACE_ID,
|
|
|
|
CONF_SERVICE_ID,
|
|
|
|
DOMAIN,
|
|
|
|
)
|
|
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(name="config_entry")
|
2022-10-08 21:06:10 +00:00
|
|
|
def config_entry_fixture(hass, config):
|
2022-01-24 14:51:30 +00:00
|
|
|
"""Define a config entry fixture."""
|
2022-10-08 21:06:10 +00:00
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
unique_id=f"{config[CONF_PLACE_ID]}, {config[CONF_SERVICE_ID]}",
|
|
|
|
data=config,
|
|
|
|
)
|
2022-01-24 14:51:30 +00:00
|
|
|
entry.add_to_hass(hass)
|
|
|
|
return entry
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(name="config")
|
|
|
|
def config_fixture(hass):
|
|
|
|
"""Define a config entry data fixture."""
|
|
|
|
return {
|
|
|
|
CONF_PLACE_ID: "12345",
|
|
|
|
CONF_SERVICE_ID: "12345",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(name="setup_recollect_waste")
|
|
|
|
async def setup_recollect_waste_fixture(hass, config):
|
|
|
|
"""Define a fixture to set up ReCollect Waste."""
|
2022-01-24 15:18:22 +00:00
|
|
|
pickup_event = PickupEvent(
|
|
|
|
date(2022, 1, 23), [PickupType("garbage", "Trash Collection")], "The Sun"
|
|
|
|
)
|
|
|
|
|
2022-01-24 14:51:30 +00:00
|
|
|
with patch(
|
2022-01-24 15:18:22 +00:00
|
|
|
"homeassistant.components.recollect_waste.Client.async_get_pickup_events",
|
|
|
|
return_value=[pickup_event],
|
2022-01-24 14:51:30 +00:00
|
|
|
), patch(
|
2022-01-24 15:18:22 +00:00
|
|
|
"homeassistant.components.recollect_waste.config_flow.Client.async_get_pickup_events",
|
|
|
|
return_value=[pickup_event],
|
2022-01-24 14:51:30 +00:00
|
|
|
), patch(
|
|
|
|
"homeassistant.components.recollect_waste.PLATFORMS", []
|
|
|
|
):
|
|
|
|
assert await async_setup_component(hass, DOMAIN, config)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
yield
|