mirror of
https://github.com/home-assistant/core.git
synced 2025-08-13 15:30:03 +00:00
.devcontainer
.github
.vscode
homeassistant
machine
pylint
rootfs
script
tests
auth
components
abode
acaia
accuweather
acmeda
adax
adguard
advantage_air
aemet
aftership
agent_dvr
air_quality
airgradient
airly
airnow
airq
airthings
airthings_ble
airtouch4
airtouch5
airvisual
airvisual_pro
airzone
airzone_cloud
aladdin_connect
alarm_control_panel
alarmdecoder
alert
alexa
amberelectric
ambient_network
ambient_station
analytics
analytics_insights
android_ip_webcam
androidtv
androidtv_remote
anova
anthemav
anthropic
aosmith
apache_kafka
apcupsd
api
api_streams
apple_tv
application_credentials
apprise
aprilaire
aprs
apsystems
aquacell
aranet
arcam_fmj
arve
aseko_pool_live
assist_pipeline
assist_satellite
asuswrt
atag
august
aurora
aurora_abb_powerone
aussie_broadband
autarco
auth
automation
awair
aws
axis
azure_data_explorer
azure_devops
azure_event_hub
azure_storage
backup
baf
balboa
bang_olufsen
bayesian
binary_sensor
blackbird
blebox
blink
blue_current
bluemaestro
blueprint
bluesound
bluetooth
bluetooth_adapters
bluetooth_le_tracker
bmw_connected_drive
bond
bosch_alarm
bosch_shc
braviatv
bring
broadlink
brother
brottsplatskartan
brunt
bryant_evolution
bsblan
bthome
buienradar
button
caldav
calendar
cambridge_audio
camera
canary
cast
ccm15
cert_expiry
chacon_dio
clicksend_tts
climate
cloud
cloudflare
co2signal
coinbase
color_extractor
comelit
comfoconnect
command_line
compensation
config
configurator
control4
conversation
cookidoo
coolmaster
counter
cover
cpuspeed
crownstone
daikin
datadog
date
datetime
deako
debugpy
deconz
default_config
deluge
demo
denonavr
derivative
devialet
device_automation
device_sun_light_trigger
device_tracker
devolo_home_control
devolo_home_network
dexcom
dhcp
diagnostics
dialogflow
directv
discord
discovergy
dlink
dlna_dmr
dlna_dms
dnsip
doorbird
dormakaba_dkey
downloader
dremel_3d_printer
drop_connect
dsmr
dsmr_reader
duckdns
duke_energy
dunehd
duotecno
dwd_weather_warnings
dynalite
eafm
easyenergy
ecobee
ecoforest
econet
ecovacs
ecowitt
edl21
efergy
eheimdigital
eight_sleep
electrasmart
electric_kiwi
elevenlabs
elgato
elkm1
elmax
elvia
emoncms
emonitor
emulated_hue
emulated_kasa
emulated_roku
energenie_power_sockets
energy
energyzero
enigma2
enocean
enphase_envoy
environment_canada
epic_games_store
epion
epson
eq3btsmart
escea
esphome
eufylife_ble
event
everlights
evil_genius_labs
evohome
ezviz
faa_delays
facebook
fail2ban
fan
fastdotcom
feedreader
ffmpeg
fibaro
fido
file
file_upload
filesize
filter
fints
fireservicerota
firmata
fitbit
fivem
fjaraskupan
flexit_bacnet
flic
flick_electric
flipr
flo
flume
flux
flux_led
folder
folder_watcher
foobot
forecast_solar
forked_daapd
foscam
freebox
freedns
freedompro
fritz
fritzbox
fritzbox_callmonitor
fronius
frontend
frontier_silicon
fujitsu_fglair
fully_kiosk
fyta
garages_amsterdam
gardena_bluetooth
gdacs
generic
generic_hygrostat
generic_thermostat
geniushub
geo_json_events
geo_location
geo_rss_events
geocaching
geofency
geonetnz_quakes
geonetnz_volcano
gios
github
glances
go2rtc
goalzero
gogogate2
goodwe
google
google_assistant
google_assistant_sdk
google_cloud
google_drive
google_generative_ai_conversation
google_mail
google_photos
google_pubsub
google_sheets
google_tasks
google_translate
google_travel_time
google_wifi
govee_ble
govee_light_local
gpsd
gpslogger
graphite
gree
greeneye_monitor
group
growatt_server
guardian
habitica
hardkernel
hardware
harmony
hassio
hddtemp
hdmi_cec
heos
here_travel_time
hisense_aehw4a1
history
history_stats
hive
hko
hlk_sw16
holiday
home_connect
homeassistant
homeassistant_alerts
homeassistant_green
homeassistant_hardware
homeassistant_sky_connect
homeassistant_yellow
homee
homekit
homekit_controller
homematic
homematicip_cloud
homewizard
homeworks
honeywell
html5
http
huawei_lte
hue
fixtures
__init__.py
conftest.py
const.py
test_binary_sensor.py
test_bridge.py
test_config_flow.py
test_device_trigger_v1.py
test_device_trigger_v2.py
test_diagnostics.py
test_event.py
test_init.py
test_light_v1.py
test_light_v2.py
test_migration.py
test_scene.py
test_sensor_v1.py
test_sensor_v2.py
test_services.py
test_switch.py
huisbaasje
humidifier
hunterdouglas_powerview
husqvarna_automower
husqvarna_automower_ble
huum
hvv_departures
hydrawise
hyperion
ialarm
iaqualink
ibeacon
icloud
idasen_desk
ifttt
igloohome
ign_sismologia
image
image_processing
image_upload
imap
imeon_inverter
imgw_pib
improv_ble
incomfort
influxdb
inkbird
input_boolean
input_button
input_datetime
input_number
input_select
input_text
insteon
integration
intellifire
intent
intent_script
iometer
ios
iotawatt
iotty
ipma
ipp
iqvia
iron_os
isal
iskra
islamic_prayer_times
israel_rail
iss
ista_ecotrend
isy994
ituran
izone
jellyfin
jewish_calendar
juicenet
justnimbus
jvc_projector
kaleidescape
keenetic_ndms2
kegtron
keymitt_ble
kira
kitchen_sink
kmtronic
knocki
knx
kodi
konnected
kostal_plenticore
kraken
kulersky
lacrosse_view
lamarzocco
lametric
landisgyr_heat_meter
lastfm
launch_library
laundrify
lawn_mower
lcn
ld2410_ble
leaone
led_ble
lektrico
letpot
lg_netcast
lg_soundbar
lg_thinq
lidarr
life360
lifx
light
linear_garage_door
linkplay
litejet
litterrobot
livisi
local_calendar
local_file
local_ip
local_todo
locative
lock
logbook
logentries
logger
london_air
london_underground
lookin
loqed
lovelace
luftdaten
lupusec
lutron
lutron_caseta
lyric
madvr
mailgun
manual
manual_mqtt
marytts
mastodon
matrix
matter
maxcube
mazda
mcp
mcp_server
mealie
meater
medcom_ble
media_extractor
media_player
media_source
melcloud
melissa
melnor
meraki
met
met_eireann
meteo_france
meteoclimatic
metoffice
mfi
microbees
microsoft
microsoft_face
microsoft_face_detect
microsoft_face_identify
miele
mikrotik
mill
min_max
minecraft_server
minio
mjpeg
moat
mobile_app
mochad
modbus
modem_callerid
modern_forms
moehlenhoff_alpha2
mold_indicator
monarch_money
monoprice
monzo
moon
mopeka
motion_blinds
motionblinds_ble
motioneye
motionmount
mpd
mqtt
mqtt_eventstream
mqtt_json
mqtt_room
mqtt_statestream
mullvad
music_assistant
mutesync
my
myq
mysensors
mystrom
mythicbeastsdns
myuplink
nam
namecheapdns
nanoleaf
nasweb
neato
ness_alarm
nest
netatmo
netgear
netgear_lte
network
nexia
nextbus
nextcloud
nextdns
nfandroidtv
nibe_heatpump
nice_go
nightscout
niko_home_control
nina
nmap_tracker
nmbs
no_ip
nobo_hub
nordpool
notify
notify_events
notion
nsw_fuel_station
nsw_rural_fire_service_feed
nuheat
nuki
numato
number
nut
nws
nx584
nyt_games
nzbget
obihai
octoprint
ohme
ollama
omnilogic
onboarding
oncue
ondilo_ico
onedrive
onewire
onkyo
onvif
open_meteo
openai_conversation
openalpr_cloud
openerz
openexchangerates
opengarage
openhardwaremonitor
openhome
opensky
opentherm_gw
openuv
openweathermap
opnsense
opower
oralb
osoenergy
otbr
otp
ourgroceries
overkiz
overseerr
ovo_energy
owntracks
p1_monitor
palazzetti
panasonic_viera
panel_custom
peblar
peco
pegel_online
permobil
persistent_notification
person
pglab
philips_js
pi_hole
picnic
pilight
ping
pjlink
plaato
plant
plex
plugwise
plum_lightpad
point
poolsense
powerfox
powerwall
private_ble_device
profiler
progettihwsw
prometheus
prosegur
proximity
prusalink
ps4
pterodactyl
pure_energie
purpleair
push
pushbullet
pushover
pvoutput
pvpc_hourly_pricing
pyload
python_script
qbittorrent
qbus
qingping
qld_bushfire
qnap
qnap_qsw
qwikswitch
rabbitair
rachio
radarr
radio_browser
radiotherm
rainbird
rainforest_eagle
rainforest_raven
rainmachine
random
rapt_ble
raspberry_pi
rdw
recollect_waste
recorder
recovery_mode
reddit
refoss
remember_the_milk
remote
remote_calendar
renault
renson
reolink
repairs
rest
rest_command
rflink
rfxtrx
rhasspy
ridwell
ring
risco
rituals_perfume_genie
rmvtransport
roborock
roku
romy
roomba
roon
rova
rpi_power
rss_feed_template
rtsp_to_webrtc
ruckus_unleashed
russound_rio
ruuvi_gateway
ruuvitag_ble
rympro
sabnzbd
samsungtv
sanix
scene
schedule
schlage
scrape
screenlogic
script
search
season
select
sense
sensibo
sensirion_ble
sensor
sensorpro
sensorpush
sensorpush_cloud
sensoterra
sentry
senz
seventeentrack
sfr_box
sharkiq
shell_command
shelly
shopping_list
sia
sigfox
sighthound
signal_messenger
simplefin
simplepush
simplisafe
siren
sky_remote
skybell
slack
sleepiq
slide_local
slimproto
sma
smappee
smart_meter_texas
smartthings
smarttub
smarty
smhi
smlight
sms
smtp
snapcast
snips
snmp
snoo
snooz
solaredge
solarlog
solax
soma
somfy_mylink
sonarr
songpal
sonos
soundtouch
spaceapi
spc
speedtestdotnet
spider
spotify
sql
squeezebox
srp_energy
ssdp
starline
starlink
startca
statistics
statsd
steam_online
steamist
stookwijzer
stream
streamlabswater
stt
subaru
suez_water
sun
sunweg
surepetcare
swiss_public_transport
switch
switch_as_x
switchbee
switchbot
switchbot_cloud
switcher_kis
syncthing
syncthru
synology_dsm
system_bridge
system_health
system_log
systemmonitor
tado
tag
tailscale
tailwind
tami4
tankerkoenig
tasmota
tautulli
tcp
technove
tedee
telegram
telegram_bot
tellduslive
temper
template
tesla_fleet
tesla_wall_connector
teslemetry
tessie
text
thermobeacon
thermopro
thethingsnetwork
thread
threshold
tibber
tile
tilt_ble
time
time_date
timer
tod
todo
todoist
tolo
tomato
tomorrowio
toon
totalconnect
touchline_sl
tplink
tplink_omada
traccar
traccar_server
trace
tractive
tradfri
trafikverket_camera
trafikverket_ferry
trafikverket_train
trafikverket_weatherstation
transmission
transport_nsw
trend
triggercmd
tts
tuya
twentemilieu
twilio
twinkly
twitch
uk_transport
ukraine_alarm
unifi
unifiprotect
universal
upb
upcloud
update
upnp
uptime
uptimerobot
usb
usgs_earthquakes_feed
utility_meter
uvc
v2c
vacuum
vallox
valve
velbus
velux
venstar
vera
verisure
version
vesync
vicare
vilfo
vizio
vlc_telnet
vodafone_station
voicerss
voip
volumio
volvooncall
vulcan
vultr
wake_on_lan
wake_word
wallbox
waqi
water_heater
watergate
watttime
waze_travel_time
weather
weatherflow
weatherflow_cloud
weatherkit
webdav
webhook
webmin
webostv
websocket_api
weheat
wemo
whirlpool
whois
wiffi
wilight
withings
wiz
wled
wmspro
wolflink
workday
worldclock
ws66i
wsdot
wyoming
xbox
xiaomi
xiaomi_aqara
xiaomi_ble
xiaomi_miio
yale
yale_smart_alarm
yalexs_ble
yamaha
yamaha_musiccast
yandex_transport
yandextts
yardian
yeelight
yolink
youless
youtube
zamg
zeroconf
zerproc
zeversolar
zha
zodiac
zone
zwave_js
zwave_me
__init__.py
conftest.py
fixtures
hassfest
helpers
non_packaged_scripts
pylint
resources
script
scripts
snapshots
test_util
testing_config
util
__init__.py
common.py
conftest.py
ignore_uncaught_exceptions.py
patch_recorder.py
patch_time.py
ruff.toml
syrupy.py
test_backports.py
test_backup_restore.py
test_block_async_io.py
test_bootstrap.py
test_circular_imports.py
test_config.py
test_config_entries.py
test_const.py
test_core.py
test_core_config.py
test_data_entry_flow.py
test_exceptions.py
test_loader.py
test_main.py
test_requirements.py
test_runner.py
test_setup.py
test_test_fixtures.py
typing.py
.core_files.yaml
.dockerignore
.git-blame-ignore-revs
.gitattributes
.gitignore
.hadolint.yaml
.pre-commit-config.yaml
.prettierignore
.strict-typing
.yamllint
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
Dockerfile.dev
LICENSE.md
MANIFEST.in
README.rst
build.yaml
codecov.yml
mypy.ini
pyproject.toml
requirements.txt
requirements_all.txt
requirements_test.txt
requirements_test_all.txt
requirements_test_pre_commit.txt
286 lines
8.9 KiB
Python
286 lines
8.9 KiB
Python
"""Test helpers for Hue."""
|
|
|
|
import asyncio
|
|
from collections import deque
|
|
from collections.abc import Generator
|
|
import logging
|
|
from typing import Any
|
|
from unittest.mock import AsyncMock, Mock, patch
|
|
|
|
import aiohue.v1 as aiohue_v1
|
|
import aiohue.v2 as aiohue_v2
|
|
from aiohue.v2.controllers.events import EventType
|
|
import pytest
|
|
|
|
from homeassistant.components import hue
|
|
from homeassistant.components.hue.v1 import sensor_base as hue_sensor_base
|
|
from homeassistant.components.hue.v2.device import async_setup_devices
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.setup import async_setup_component
|
|
from homeassistant.util.json import JsonArrayType
|
|
|
|
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
|
|
|
|
from tests.common import MockConfigEntry, load_json_array_fixture
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_request_delay() -> Generator[None]:
|
|
"""Make the request refresh delay 0 for instant tests."""
|
|
with patch("homeassistant.components.hue.const.REQUEST_REFRESH_DELAY", 0):
|
|
yield
|
|
|
|
|
|
def create_mock_bridge(hass: HomeAssistant, api_version: int = 1) -> Mock:
|
|
"""Create a mocked HueBridge instance."""
|
|
bridge = Mock(
|
|
hass=hass,
|
|
authorized=True,
|
|
config_entry=None,
|
|
reset_jobs=[],
|
|
api_version=api_version,
|
|
spec=hue.HueBridge,
|
|
)
|
|
|
|
bridge.logger = logging.getLogger(__name__)
|
|
|
|
if bridge.api_version == 2:
|
|
bridge.api = create_mock_api_v2()
|
|
bridge.mock_requests = bridge.api.mock_requests
|
|
else:
|
|
bridge.api = create_mock_api_v1()
|
|
bridge.sensor_manager = hue_sensor_base.SensorManager(bridge)
|
|
bridge.mock_requests = bridge.api.mock_requests
|
|
bridge.mock_light_responses = bridge.api.mock_light_responses
|
|
bridge.mock_group_responses = bridge.api.mock_group_responses
|
|
bridge.mock_sensor_responses = bridge.api.mock_sensor_responses
|
|
|
|
async def async_initialize_bridge():
|
|
if bridge.config_entry:
|
|
hass.data.setdefault(hue.DOMAIN, {})[bridge.config_entry.entry_id] = bridge
|
|
if bridge.api_version == 2:
|
|
await async_setup_devices(bridge)
|
|
return True
|
|
|
|
bridge.async_initialize_bridge = async_initialize_bridge
|
|
|
|
async def async_request_call(task, *args, **kwargs):
|
|
await task(*args, **kwargs)
|
|
|
|
bridge.async_request_call = async_request_call
|
|
|
|
async def async_reset():
|
|
if bridge.config_entry:
|
|
hass.data[hue.DOMAIN].pop(bridge.config_entry.entry_id)
|
|
return True
|
|
|
|
bridge.async_reset = async_reset
|
|
|
|
return bridge
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_api_v1() -> Mock:
|
|
"""Mock the Hue V1 api."""
|
|
return create_mock_api_v1()
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_api_v2() -> Mock:
|
|
"""Mock the Hue V2 api."""
|
|
return create_mock_api_v2()
|
|
|
|
|
|
def create_mock_api_v1() -> Mock:
|
|
"""Create a mock V1 API."""
|
|
api = Mock(spec=aiohue_v1.HueBridgeV1)
|
|
api.initialize = AsyncMock()
|
|
api.mock_requests = []
|
|
api.mock_light_responses = deque()
|
|
api.mock_group_responses = deque()
|
|
api.mock_sensor_responses = deque()
|
|
api.mock_scene_responses = deque()
|
|
|
|
async def mock_request(method, path, **kwargs):
|
|
kwargs["method"] = method
|
|
kwargs["path"] = path
|
|
api.mock_requests.append(kwargs)
|
|
|
|
if path == "lights":
|
|
return api.mock_light_responses.popleft()
|
|
if path == "groups":
|
|
return api.mock_group_responses.popleft()
|
|
if path == "sensors":
|
|
return api.mock_sensor_responses.popleft()
|
|
if path == "scenes":
|
|
return api.mock_scene_responses.popleft()
|
|
return None
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
api.config = Mock(
|
|
bridge_id="ff:ff:ff:ff:ff:ff",
|
|
mac_address="aa:bb:cc:dd:ee:ff",
|
|
model_id="BSB002",
|
|
apiversion="9.9.9",
|
|
software_version="1935144040",
|
|
)
|
|
api.config.name = "Home"
|
|
|
|
api.lights = aiohue_v1.Lights(logger, {}, mock_request)
|
|
api.groups = aiohue_v1.Groups(logger, {}, mock_request)
|
|
api.sensors = aiohue_v1.Sensors(logger, {}, mock_request)
|
|
api.scenes = aiohue_v1.Scenes(logger, {}, mock_request)
|
|
return api
|
|
|
|
|
|
@pytest.fixture(scope="package")
|
|
def v2_resources_test_data() -> JsonArrayType:
|
|
"""Load V2 resources mock data."""
|
|
return load_json_array_fixture("hue/v2_resources.json")
|
|
|
|
|
|
def create_mock_api_v2() -> Mock:
|
|
"""Create a mock V2 API."""
|
|
api = Mock(spec=aiohue_v2.HueBridgeV2)
|
|
api.initialize = AsyncMock()
|
|
api.mock_requests = []
|
|
|
|
api.logger = logging.getLogger(__name__)
|
|
api.config = aiohue_v2.ConfigController(api)
|
|
api.events = aiohue_v2.EventStream(api)
|
|
api.devices = aiohue_v2.DevicesController(api)
|
|
api.lights = aiohue_v2.LightsController(api)
|
|
api.sensors = aiohue_v2.SensorsController(api)
|
|
api.groups = aiohue_v2.GroupsController(api)
|
|
api.scenes = aiohue_v2.ScenesController(api)
|
|
|
|
async def mock_request(method, path, **kwargs):
|
|
kwargs["method"] = method
|
|
kwargs["path"] = path
|
|
api.mock_requests.append(kwargs)
|
|
return kwargs.get("json")
|
|
|
|
api.request = mock_request
|
|
|
|
async def load_test_data(data: list[dict[str, Any]]):
|
|
"""Load test data into controllers."""
|
|
|
|
# append default bridge if none explicitly given in test data
|
|
if not any(x for x in data if x["type"] == "bridge"):
|
|
data.append(FAKE_BRIDGE)
|
|
data.append(FAKE_BRIDGE_DEVICE)
|
|
|
|
await asyncio.gather(
|
|
api.config.initialize(data),
|
|
api.devices.initialize(data),
|
|
api.lights.initialize(data),
|
|
api.scenes.initialize(data),
|
|
api.sensors.initialize(data),
|
|
api.groups.initialize(data),
|
|
)
|
|
|
|
def emit_event(event_type, data):
|
|
"""Emit an event from a (hue resource) dict."""
|
|
api.events.emit(EventType(event_type), data)
|
|
|
|
api.load_test_data = load_test_data
|
|
api.emit_event = emit_event
|
|
# mock context manager too
|
|
api.__aenter__ = AsyncMock(return_value=api)
|
|
api.__aexit__ = AsyncMock()
|
|
return api
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_bridge_v1(hass: HomeAssistant) -> Mock:
|
|
"""Mock a Hue bridge with V1 api."""
|
|
return create_mock_bridge(hass, api_version=1)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_bridge_v2(hass: HomeAssistant) -> Mock:
|
|
"""Mock a Hue bridge with V2 api."""
|
|
return create_mock_bridge(hass, api_version=2)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config_entry_v1() -> MockConfigEntry:
|
|
"""Mock a config entry for a Hue V1 bridge."""
|
|
return create_config_entry(api_version=1)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config_entry_v2() -> MockConfigEntry:
|
|
"""Mock a config entry."""
|
|
return create_config_entry(api_version=2)
|
|
|
|
|
|
def create_config_entry(
|
|
api_version: int = 1, host: str = "mock-host"
|
|
) -> MockConfigEntry:
|
|
"""Mock a config entry for a Hue bridge."""
|
|
return MockConfigEntry(
|
|
domain=hue.DOMAIN,
|
|
title=f"Mock bridge {api_version}",
|
|
data={"host": host, "api_version": api_version, "api_key": ""},
|
|
)
|
|
|
|
|
|
async def setup_component(hass: HomeAssistant) -> None:
|
|
"""Mock setup Hue component."""
|
|
with patch.object(hue, "async_setup_entry", return_value=True):
|
|
assert (
|
|
await async_setup_component(
|
|
hass,
|
|
hue.DOMAIN,
|
|
{},
|
|
)
|
|
is True
|
|
)
|
|
|
|
|
|
async def setup_bridge(
|
|
hass: HomeAssistant, mock_bridge: Mock, config_entry: MockConfigEntry
|
|
) -> None:
|
|
"""Load the Hue integration with the provided bridge."""
|
|
mock_bridge.config_entry = config_entry
|
|
with patch.object(
|
|
hue.migration, "is_v2_bridge", return_value=mock_bridge.api_version == 2
|
|
):
|
|
config_entry.add_to_hass(hass)
|
|
with patch("homeassistant.components.hue.HueBridge", return_value=mock_bridge):
|
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
|
async def setup_platform(
|
|
hass: HomeAssistant,
|
|
mock_bridge: Mock,
|
|
platforms: list[Platform] | tuple[Platform] | Platform,
|
|
hostname: str | None = None,
|
|
) -> None:
|
|
"""Load the Hue integration with the provided bridge for given platform(s)."""
|
|
if not isinstance(platforms, (list, tuple)):
|
|
platforms = [platforms]
|
|
if hostname is None:
|
|
hostname = "mock-host"
|
|
hass.config.components.add(hue.DOMAIN)
|
|
config_entry = create_config_entry(
|
|
api_version=mock_bridge.api_version, host=hostname
|
|
)
|
|
mock_bridge.config_entry = config_entry
|
|
hass.data[hue.DOMAIN] = {config_entry.entry_id: mock_bridge}
|
|
|
|
# simulate a full setup by manually adding the bridge config entry
|
|
await setup_bridge(hass, mock_bridge, config_entry)
|
|
assert await async_setup_component(hass, hue.DOMAIN, {}) is True
|
|
await hass.async_block_till_done()
|
|
|
|
config_entry.mock_state(hass, ConfigEntryState.LOADED)
|
|
await hass.config_entries.async_forward_entry_setups(config_entry, platforms)
|
|
|
|
# and make sure it completes before going further
|
|
await hass.async_block_till_done()
|