1
0
mirror of https://github.com/home-assistant/core.git synced 2025-08-10 22:10:02 +00:00
Files
.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
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
fixtures
snapshots
__init__.py
conftest.py
test_climate.py
test_config_flow.py
test_data.py
test_diagnostics.py
test_init.py
test_services.py
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
core/tests/components/screenlogic/test_config_flow.py
Kevin Worrel b8d74a11ae Allow ignored screenlogic devices to be set up from the user flow ()
Allow ignored ScreenLogic devices to be set up from the user flow
2025-02-04 21:12:49 +01:00

382 lines
12 KiB
Python

"""Test the Pentair ScreenLogic config flow."""
from unittest.mock import patch
from screenlogicpy import ScreenLogicError
from screenlogicpy.const.common import (
SL_GATEWAY_IP,
SL_GATEWAY_NAME,
SL_GATEWAY_PORT,
SL_GATEWAY_SUBTYPE,
SL_GATEWAY_TYPE,
)
from homeassistant import config_entries
from homeassistant.components.screenlogic.config_flow import (
GATEWAY_MANUAL_ENTRY,
GATEWAY_SELECT_KEY,
)
from homeassistant.components.screenlogic.const import (
DEFAULT_SCAN_INTERVAL,
DOMAIN,
MIN_SCAN_INTERVAL,
)
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
from tests.common import MockConfigEntry
async def test_flow_discovery(hass: HomeAssistant) -> None:
"""Test the flow works with basic discovery."""
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[
{
SL_GATEWAY_IP: "1.1.1.1",
SL_GATEWAY_PORT: 80,
SL_GATEWAY_TYPE: 12,
SL_GATEWAY_SUBTYPE: 2,
SL_GATEWAY_NAME: "Pentair: 01-01-01",
},
],
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "gateway_select"
with patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={GATEWAY_SELECT_KEY: "00:c0:33:01:01:01"}
)
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Pentair: 01-01-01"
assert result2["data"] == {
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_flow_discover_none(hass: HomeAssistant) -> None:
"""Test when nothing is discovered."""
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[],
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "gateway_entry"
async def test_flow_replace_ignored(hass: HomeAssistant) -> None:
"""Test we can replace ignored entries."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="00:c0:33:01:01:01",
source=config_entries.SOURCE_IGNORE,
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[
{
SL_GATEWAY_IP: "1.1.1.1",
SL_GATEWAY_PORT: 80,
SL_GATEWAY_TYPE: 12,
SL_GATEWAY_SUBTYPE: 2,
SL_GATEWAY_NAME: "Pentair: 01-01-01",
},
],
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "gateway_select"
with patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={GATEWAY_SELECT_KEY: "00:c0:33:01:01:01"}
)
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Pentair: 01-01-01"
assert result2["data"] == {
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_flow_discover_error(hass: HomeAssistant) -> None:
"""Test when discovery errors."""
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
side_effect=ScreenLogicError("Fake error"),
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "gateway_entry"
with (
patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
) as mock_setup_entry,
patch(
"homeassistant.components.screenlogic.config_flow.login.async_get_mac_address",
return_value="00-C0-33-01-01-01",
),
):
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
},
)
await hass.async_block_till_done()
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "Pentair: 01-01-01"
assert result3["data"] == {
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_dhcp(hass: HomeAssistant) -> None:
"""Test DHCP discovery flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_DHCP},
data=DhcpServiceInfo(
hostname="Pentair: 01-01-01",
ip="1.1.1.1",
macaddress="aabbccddeeff",
),
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "gateway_entry"
with (
patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
) as mock_setup_entry,
patch(
"homeassistant.components.screenlogic.config_flow.login.async_get_mac_address",
return_value="00-C0-33-01-01-01",
),
):
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
},
)
await hass.async_block_till_done()
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "Pentair: 01-01-01"
assert result3["data"] == {
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_manual_entry(hass: HomeAssistant) -> None:
"""Test we get the form."""
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[
{
SL_GATEWAY_IP: "1.1.1.1",
SL_GATEWAY_PORT: 80,
SL_GATEWAY_TYPE: 12,
SL_GATEWAY_SUBTYPE: 2,
SL_GATEWAY_NAME: "Pentair: 01-01-01",
},
],
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "gateway_select"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={GATEWAY_SELECT_KEY: GATEWAY_MANUAL_ENTRY}
)
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {}
assert result2["step_id"] == "gateway_entry"
with (
patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
) as mock_setup_entry,
patch(
"homeassistant.components.screenlogic.config_flow.login.async_get_mac_address",
return_value="00-C0-33-01-01-01",
),
):
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
},
)
await hass.async_block_till_done()
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "Pentair: 01-01-01"
assert result3["data"] == {
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
"""Test we handle cannot connect error."""
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[],
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.screenlogic.config_flow.login.async_get_mac_address",
side_effect=ScreenLogicError("Failed to connect to host at 1.1.1.1:80"),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_IP_ADDRESS: "1.1.1.1",
CONF_PORT: 80,
},
)
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
async def test_option_flow(hass: HomeAssistant) -> None:
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={CONF_SCAN_INTERVAL: 15},
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {CONF_SCAN_INTERVAL: 15}
async def test_option_flow_defaults(hass: HomeAssistant) -> None:
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL,
}
async def test_option_flow_input_floor(hass: HomeAssistant) -> None:
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.screenlogic.async_setup_entry",
return_value=True,
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_SCAN_INTERVAL: 1}
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_SCAN_INTERVAL: MIN_SCAN_INTERVAL,
}