2019-12-08 08:26:31 +00:00
|
|
|
"""Tests for the Elgato Key Light integration."""
|
|
|
|
|
|
|
|
from homeassistant.components.elgato.const import CONF_SERIAL_NUMBER, DOMAIN
|
2020-09-23 18:21:55 +00:00
|
|
|
from homeassistant.const import CONF_HOST, CONF_PORT, CONTENT_TYPE_JSON
|
2019-12-08 08:26:31 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
|
|
|
from tests.common import MockConfigEntry, load_fixture
|
|
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
|
|
|
|
|
|
|
|
|
|
|
async def init_integration(
|
2020-08-27 11:56:20 +00:00
|
|
|
hass: HomeAssistant,
|
|
|
|
aioclient_mock: AiohttpClientMocker,
|
|
|
|
skip_setup: bool = False,
|
2019-12-08 08:26:31 +00:00
|
|
|
) -> MockConfigEntry:
|
|
|
|
"""Set up the Elgato Key Light integration in Home Assistant."""
|
|
|
|
|
|
|
|
aioclient_mock.get(
|
2020-08-05 09:26:17 +00:00
|
|
|
"http://1.2.3.4:9123/elgato/accessory-info",
|
2019-12-08 08:26:31 +00:00
|
|
|
text=load_fixture("elgato/info.json"),
|
2020-09-23 18:21:55 +00:00
|
|
|
headers={"Content-Type": CONTENT_TYPE_JSON},
|
2019-12-08 08:26:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
aioclient_mock.put(
|
2020-08-05 09:26:17 +00:00
|
|
|
"http://1.2.3.4:9123/elgato/lights",
|
2019-12-08 08:26:31 +00:00
|
|
|
text=load_fixture("elgato/state.json"),
|
2020-09-23 18:21:55 +00:00
|
|
|
headers={"Content-Type": CONTENT_TYPE_JSON},
|
2019-12-08 08:26:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
aioclient_mock.get(
|
2020-08-05 09:26:17 +00:00
|
|
|
"http://1.2.3.4:9123/elgato/lights",
|
2019-12-08 08:26:31 +00:00
|
|
|
text=load_fixture("elgato/state.json"),
|
2020-09-23 18:21:55 +00:00
|
|
|
headers={"Content-Type": CONTENT_TYPE_JSON},
|
2019-12-08 08:26:31 +00:00
|
|
|
)
|
|
|
|
|
2020-08-05 09:26:17 +00:00
|
|
|
aioclient_mock.get(
|
|
|
|
"http://5.6.7.8:9123/elgato/accessory-info",
|
|
|
|
text=load_fixture("elgato/info.json"),
|
2020-09-23 18:21:55 +00:00
|
|
|
headers={"Content-Type": CONTENT_TYPE_JSON},
|
2020-08-05 09:26:17 +00:00
|
|
|
)
|
|
|
|
|
2019-12-08 08:26:31 +00:00
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
2020-01-04 21:45:11 +00:00
|
|
|
unique_id="CN11A1A00001",
|
2019-12-08 08:26:31 +00:00
|
|
|
data={
|
2020-08-05 09:26:17 +00:00
|
|
|
CONF_HOST: "1.2.3.4",
|
2019-12-08 08:26:31 +00:00
|
|
|
CONF_PORT: 9123,
|
|
|
|
CONF_SERIAL_NUMBER: "CN11A1A00001",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
if not skip_setup:
|
|
|
|
await hass.config_entries.async_setup(entry.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
return entry
|