-
-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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
Refactor RDW tests #118232
base: dev
Are you sure you want to change the base?
Refactor RDW tests #118232
Conversation
Hey there @frenck, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
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'm not a fan of these test helpers and methods applied. I pretty much prefer no change in this case over the suggested improvement.
async def init_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None: | ||
"""Set up the RDW integration for testing.""" | ||
config_entry.add_to_hass(hass) | ||
|
||
await hass.config_entries.async_setup(config_entry.entry_id) | ||
await hass.async_block_till_done() |
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 much prefer fixtures to be used instead.
== "https://ovi.rdw.nl/default.aspx?kenteken=11ZKZ3" | ||
) | ||
assert not device_entry.sw_version | ||
with patch("homeassistant.components.rdw.PLATFORMS", [Platform.SENSOR]): |
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.
There is no need for this in these tests. Alternative, a fixture could be used for this.
assert not device_entry.sw_version | ||
with patch("homeassistant.components.rdw.PLATFORMS", [Platform.SENSOR]): | ||
await init_integration(hass, mock_config_entry) | ||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) |
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.
This degrades the testing, as devices are no longer validated.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
Refactor RDW tests
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
..coveragerc
.To help with the load of incoming pull requests: