1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-21 16:00:12 +01:00
Files
core/tests/components/youless/__init__.py
T
epenet 3222472f10 Use runtime_data in youless (#168694)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-21 12:44:18 +02:00

45 lines
1.3 KiB
Python

"""Tests for the youless component."""
import requests_mock
from homeassistant.components.youless.const import DOMAIN
from homeassistant.const import CONF_DEVICE, CONF_HOST
from homeassistant.core import HomeAssistant
from tests.common import (
MockConfigEntry,
async_load_json_array_fixture,
async_load_json_object_fixture,
)
async def init_component(hass: HomeAssistant) -> MockConfigEntry:
"""Check if the setup of the integration succeeds."""
with requests_mock.Mocker() as mock:
mock.get(
"http://1.1.1.1/d",
json=await async_load_json_object_fixture(hass, "device.json", DOMAIN),
)
mock.get(
"http://1.1.1.1/e",
json=await async_load_json_array_fixture(hass, "enologic.json", DOMAIN),
headers={"Content-Type": "application/json"},
)
mock.get(
"http://1.1.1.1/f",
json=await async_load_json_object_fixture(hass, "phase.json", DOMAIN),
headers={"Content-Type": "application/json"},
)
entry = MockConfigEntry(
domain=DOMAIN,
title="localhost",
data={CONF_HOST: "1.1.1.1", CONF_DEVICE: "localhost"},
)
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
return entry