♻️ Extract _submit_user_flow helper to collapse config-flow test boilerplate #44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "config-flow-test-helper"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Flagged in the code review of #38 (Standards axis — "Duplicated Code") but skipped there to keep that fix PR tightly scoped.
Problem
The
async_init/async_configureboilerplate for the user config flow is copy-pasted across 4 tests intests/test_config_flow.py:Change
_submit_user_flow(hass, user_input) -> FlowResult— starts the user flow, submits the input, returns the result.test_form_is_shown_first(init only, no submit) and the reauth tests (differentstart_reauth_flowshape) are left as-is.Net: -8 lines, one source of truth for "submit the user flow".
Tests
29/29, ruff clean, mypy clean.
Interaction with #38
#38 adds
test_cannot_connect_on_server_error, which also uses this boilerplate. Whichever PR merges first, the other needs a trivial rebase:_submit_user_flow(small conflict ontests/test_config_flow.py);