Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
1f7d620d
Unverified
Commit
1f7d620d
authored
1 month ago
by
Jan Bouwhuis
Committed by
GitHub
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Don't show active user initiated data entry config flows (#137334)
Do not show active user initiated data entry config flows
parent
9a9374bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/config/config_entries.py
+2
-1
2 additions, 1 deletion
homeassistant/components/config/config_entries.py
tests/components/config/test_config_entries.py
+42
-5
42 additions, 5 deletions
tests/components/config/test_config_entries.py
with
44 additions
and
6 deletions
homeassistant/components/config/config_entries.py
+
2
−
1
View file @
1f7d620d
...
...
@@ -302,7 +302,8 @@ def config_entries_progress(
[
flw
for
flw
in
hass
.
config_entries
.
flow
.
async_progress
()
if
flw
[
"
context
"
][
"
source
"
]
!=
config_entries
.
SOURCE_USER
if
flw
[
"
context
"
][
"
source
"
]
not
in
(
config_entries
.
SOURCE_RECONFIGURE
,
config_entries
.
SOURCE_USER
)
],
)
...
...
This diff is collapsed.
Click to expand it.
tests/components/config/test_config_entries.py
+
42
−
5
View file @
1f7d620d
...
...
@@ -3,6 +3,7 @@
from
collections
import
OrderedDict
from
collections.abc
import
Generator
from
http
import
HTTPStatus
from
typing
import
Any
from
unittest.mock
import
ANY
,
AsyncMock
,
patch
from
aiohttp.test_utils
import
TestClient
...
...
@@ -12,12 +13,13 @@ import voluptuous as vol
from
homeassistant
import
config_entries
as
core_ce
,
data_entry_flow
,
loader
from
homeassistant.components.config
import
config_entries
from
homeassistant.config_entries
import
HANDLERS
,
ConfigFlow
from
homeassistant.config_entries
import
HANDLERS
,
ConfigFlow
,
ConfigFlowResult
from
homeassistant.const
import
CONF_LATITUDE
,
CONF_LONGITUDE
,
CONF_RADIUS
from
homeassistant.core
import
HomeAssistant
,
callback
from
homeassistant.data_entry_flow
import
FlowResultType
from
homeassistant.helpers
import
config_entry_flow
,
config_validation
as
cv
from
homeassistant.helpers.discovery_flow
import
DiscoveryKey
from
homeassistant.helpers.service_info.hassio
import
HassioServiceInfo
from
homeassistant.loader
import
IntegrationNotFound
from
homeassistant.setup
import
async_setup_component
from
homeassistant.util.dt
import
utcnow
...
...
@@ -729,27 +731,62 @@ async def test_get_progress_index(
mock_platform
(
hass
,
"
test.config_flow
"
,
None
)
ws_client
=
await
hass_ws_client
(
hass
)
mock_integration
(
hass
,
MockModule
(
"
test
"
,
async_setup_entry
=
AsyncMock
(
return_value
=
True
))
)
entry
=
MockConfigEntry
(
domain
=
"
test
"
,
title
=
"
Test
"
,
entry_id
=
"
1234
"
)
entry
.
add_to_hass
(
hass
)
class
TestFlow
(
core_ce
.
ConfigFlow
):
VERSION
=
5
async
def
async_step_hassio
(
self
,
discovery_info
):
async
def
async_step_hassio
(
self
,
discovery_info
:
HassioServiceInfo
)
->
ConfigFlowResult
:
"""
Handle a Hass.io discovery.
"""
return
await
self
.
async_step_account
()
async
def
async_step_account
(
self
,
user_input
=
None
):
async
def
async_step_account
(
self
,
user_input
:
dict
[
str
,
Any
]
|
None
=
None
):
"""
Show a form to the user.
"""
return
self
.
async_show_form
(
step_id
=
"
account
"
)
async
def
async_step_user
(
self
,
user_input
:
dict
[
str
,
Any
]
|
None
=
None
):
"""
Handle a config flow initialized by the user.
"""
return
await
self
.
async_step_account
()
async
def
async_step_reconfigure
(
self
,
user_input
:
dict
[
str
,
Any
]
|
None
=
None
):
"""
Handle a reconfiguration flow initialized by the user.
"""
nonlocal
entry
assert
self
.
_get_reconfigure_entry
()
is
entry
return
await
self
.
async_step_account
()
with
patch
.
dict
(
HANDLERS
,
{
"
test
"
:
TestFlow
}):
form
=
await
hass
.
config_entries
.
flow
.
async_init
(
form
_hassio
=
await
hass
.
config_entries
.
flow
.
async_init
(
"
test
"
,
context
=
{
"
source
"
:
core_ce
.
SOURCE_HASSIO
}
)
form_user
=
await
hass
.
config_entries
.
flow
.
async_init
(
"
test
"
,
context
=
{
"
source
"
:
core_ce
.
SOURCE_USER
}
)
form_reconfigure
=
await
hass
.
config_entries
.
flow
.
async_init
(
"
test
"
,
context
=
{
"
source
"
:
core_ce
.
SOURCE_RECONFIGURE
,
"
entry_id
"
:
"
1234
"
}
)
for
form
in
(
form_hassio
,
form_user
,
form_reconfigure
):
assert
form
[
"
type
"
]
==
data_entry_flow
.
FlowResultType
.
FORM
assert
form
[
"
step_id
"
]
==
"
account
"
await
ws_client
.
send_json
({
"
id
"
:
5
,
"
type
"
:
"
config_entries/flow/progress
"
})
response
=
await
ws_client
.
receive_json
()
assert
response
[
"
success
"
]
# Active flows with SOURCE_USER and SOURCE_RECONFIGURE should be filtered out
assert
response
[
"
result
"
]
==
[
{
"
flow_id
"
:
form
[
"
flow_id
"
],
"
flow_id
"
:
form
_hassio
[
"
flow_id
"
],
"
handler
"
:
"
test
"
,
"
step_id
"
:
"
account
"
,
"
context
"
:
{
"
source
"
:
core_ce
.
SOURCE_HASSIO
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment