Refactor Harmony tests to better follow Home Assistant conventions #47141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
This addresses some feedback that was provided in #42331. To support it, there are a couple of high level changes made:
I slightly modified the test fixtures we use for creating and injecting our
FakeHarmonyClient
such that we share a single instance of the client across each test rather than a mocked one that is constructed each time as a side effect. This allows us to capture the callbacks passed into the Harmony client as it's created. Sorry if this is a funky way to do it, but it seemed to be the cleanest way I could figure out. This allows me to move away from getting thedata
object fromhass
to simulate hub connections and disconnections, but instead just call methods on my fake client and have those callbacks called appropriately.I mechanically moved the co-mingled tests for switches and remotes from the functionality-specific files (activity changes, etc) into the specific platform files. Generally the new platform tests are now platform specific, but I kept checks in the
toggle
style tests for the other platform. (e.g. if a switch turns on an activity, ensure the remote shows as on.)Type of change
Additional information
Checklist
black --fast 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
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: