-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add checks for config entry state in async_config_entry_first_refresh #128148
Conversation
The PR description does not say why it should not be supported? |
PR description updated. If it is called after the entry has been setup, then |
entry = MockConfigEntry() | ||
crd = get_crd(hass, DEFAULT_UPDATE_INTERVAL, entry) | ||
crd.setup_method = AsyncMock() | ||
with pytest.raises( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a test when it doesn't raise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a test when it doesn't raise?
We have already : test_async_config_entry_first_refresh_success
just above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean more explicitly that this raises because it's not coming from an integration (same with above but the config entry state is then ok).
So should we also have a test when raised from an integration that it's only logging and not raising (as that is the intention)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok!
Test added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks, @epenet 👍
../Frenck
@@ -18,6 +19,7 @@ | |||
async def test_coordinator_device_info(hass: HomeAssistant) -> None: | |||
"""Test reporting device information from the coordinator.""" | |||
entry = create_mock_entry() | |||
entry._async_set_state(hass, ConfigEntryState.SETUP_IN_PROGRESS, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to refactor these tests to not depend on integration details like the coordinator since these tests pop up failing all the time when we refactor things in helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to refactor these tests to not depend on integration details like the coordinator since these tests pop up failing all the time when we refactor things in helpers.
First step: #128517 moves to runtime data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to refactor these tests to not depend on integration details like the coordinator since these tests pop up failing all the time when we refactor things in helpers.
First step: #128517 moves to runtime data
Second step: #128591 adds abstraction to the initialisation and device_registry tests
Breaking change
Proposed change
It should not be possible to call
async_config_entry_first_refresh
if a config entry is not inSETUP_IN_PROGRESS
.If it is called after the entry has been setup, then
ConfigEntryNotReady
will be raised but not handled, and failures will not be logged. It could also then be called more than once - leading to multiple calls toasync_setup
Needs:
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: