-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
Refactor TP-Link Omada config flow tests #159950
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
base: dev
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR refactors the TP-Link Omada config flow tests in response to feedback from #156697, improving test quality while maintaining 100% test coverage. The refactoring removes patching of internal config flow functions and instead mocks external APIs, following Home Assistant testing best practices.
Key changes:
- Introduces proper test fixtures that mock the Omada client API instead of internal validation functions
- Consolidates multiple error handling tests into parametrized tests to reduce code duplication
- Adds controller ID validation during reauthentication to prevent users from reauthenticating with a different controller
- Updates quality scale status from "todo" to "done" for config-flow-test-coverage
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/components/tplink_omada/test_config_flow.py | Refactors config flow tests to mock external APIs, adds fixtures for test setup, consolidates error tests using parametrization, and improves test coverage verification |
| homeassistant/components/tplink_omada/config_flow.py | Adds controller ID validation in reauth flow to prevent reauthenticating with a different controller |
| homeassistant/components/tplink_omada/strings.json | Adds user-facing abort message for device mismatch during reauth |
| homeassistant/components/tplink_omada/quality_scale.yaml | Updates config-flow-test-coverage rule from todo to done status |
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
Changes requested in #156697. This retains 100% coverage of the config flow, and improves the test quality.
I think this gets to bronze quality level. If this passes, I'll put in a PR to bump it.
Bronze
action-setup- Service actions are registered in async_setupappropriate-polling- If it's a polling integration, set an appropriate polling intervalbrands- Has branding assets available for the integrationcommon-modules- Place common patterns in common modulesconfig-flow-test-coverage- Full test coverage for the config flowconfig-flow- Integration needs to be able to be set up via the UIdata_descriptionto give context to fieldsConfigEntry.dataandConfigEntry.optionscorrectlydependency-transparency- Dependency transparencydocs-actions- The documentation describes the provided service actions that can be useddocs-high-level-description- The documentation includes a high-level description of the integration brand, product, or servicedocs-installation-instructions- The documentation provides step-by-step installation instructions for the integration, including, if needed, prerequisitesdocs-removal-instructions- The documentation provides removal instructionsentity-event-setup- Entity events are subscribed in the correct lifecycle methodsentity-unique-id- Entities have a unique IDhas-entity-name- Entities use has_entity_name = Trueruntime-data- Use ConfigEntry.runtime_data to store runtime datatest-before-configure- Test a connection in the config flowtest-before-setup- Check during integration initialization if we are able to set it up correctlyunique-config-entry- Don't allow the same device or service to be able to be set up twiceType 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: