* Add WLED integration * Use f-string for uniq id in sensor platform * Typing improvements * Removes sensor & light platform * Remove PARALLEL_UPDATES from integration level * Correct type in code comment 'themselves' * Use async_track_time_interval in async context * Remove stale code * Remove decorator from Flow handler * Remove unused __init__ from config flow * Move show form methods to sync * Only wrap lines that can raise in try except block * Remove domain and platform from uniq id * Wrap light state in bool object in is_on method * Use async_schedule_update_ha_state in async context * Return empty dict in device state attributes instead of None * Remove unneeded setdefault call in setup entry * Cancel update timer on entry unload * Restructure config flow code * Adjust tests for new uniq id * Correct typo AdGuard Home -> WLED in config flow file comment * Convert internal package imports to be relative * Reformat JSON files with Prettier * Improve tests based on review comments * Add test for zeroconf when no data is provided * Cleanup and extended tests
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Tests for the WLED integration."""
|
|
|
|
from homeassistant.components.wled.const import DOMAIN
|
|
from homeassistant.const import CONF_HOST, CONF_MAC
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from tests.common import MockConfigEntry, load_fixture
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
|
|
|
|
|
async def init_integration(
|
|
hass: HomeAssistant,
|
|
aioclient_mock: AiohttpClientMocker,
|
|
rgbw: bool = False,
|
|
skip_setup: bool = False,
|
|
) -> MockConfigEntry:
|
|
"""Set up the WLED integration in Home Assistant."""
|
|
|
|
fixture = "wled/rgb.json" if not rgbw else "wled/rgbw.json"
|
|
aioclient_mock.get(
|
|
"http://example.local:80/json/",
|
|
text=load_fixture(fixture),
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
|
|
aioclient_mock.post(
|
|
"http://example.local:80/json/state",
|
|
json={"success": True},
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
|
|
entry = MockConfigEntry(
|
|
domain=DOMAIN, data={CONF_HOST: "example.local", CONF_MAC: "aabbccddeeff"}
|
|
)
|
|
|
|
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
|