-
Notifications
You must be signed in to change notification settings - Fork 7
Add testcases for update_interval #994
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: main
Are you sure you want to change the base?
Conversation
WalkthroughRefactors Plugwise tests to initialize integrations via config entries instead of direct component setup and adds tests asserting the integration's default update intervals for Adam (60s) and P1 (10s) using a freezer-driven coordinator update flow. Changes
Sequence Diagram(s)(omitted — changes are test-focused and do not introduce a new multi-component runtime control flow that benefits from a sequence diagram) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-08-23T16:26:34.700ZApplied to files:
📚 Learning: 2024-10-08T15:35:25.180ZApplied to files:
🧬 Code graph analysis (1)tests/components/plugwise/test_init.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/components/plugwise/snapshots/test_select.ambrtests/components/plugwise/test_init.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-23T16:26:34.700Z
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 906
File: tests/components/plugwise/test_binary_sensor.py:9-16
Timestamp: 2025-08-23T16:26:34.700Z
Learning: The Plugwise integration test files import utilities like `snapshot_platform`, `MockConfigEntry`, and `async_fire_time_changed` from `tests.common`, which is from the Home Assistant core repository at https://github.com/home-assistant/core/blob/master/tests/common.py, not from local test files.
Applied to files:
tests/components/plugwise/test_init.py
🧬 Code graph analysis (1)
tests/components/plugwise/test_init.py (1)
tests/components/plugwise/conftest.py (3)
mock_config_entry(81-95)mock_smile_adam_heat_cool(185-208)mock_smile_p1(295-317)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Prepare and validate pre-commit
🔇 Additional comments (2)
tests/components/plugwise/snapshots/test_select.ambr (1)
144-144: LGTM! Appropriate reclassification of schedule entities.The snapshot correctly reflects the reclassification of thermostat schedule select entities from
EntityCategory.CONFIGtoNone. This distinguishes user-facing operational settings (schedules) from gateway-level configuration settings, improving the UX by making schedules more prominent in the UI.Also applies to: 266-266, 389-389, 454-454, 519-519, 584-584
tests/components/plugwise/test_init.py (1)
17-17: LGTM! Necessary import for new tests.The addition of
DEFAULT_SCAN_INTERVALto the imports is required for the new update interval tests.
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/components/plugwise/test_init.py (1)
33-33: Remove the unused import.The
async_setup_componentimport is no longer needed since all tests now usehass.config_entries.async_setup(mock_config_entry.entry_id)instead. The pre-commit hook flagged this import as unused.🔎 Proposed fix
-from homeassistant.setup import async_setup_component
♻️ Duplicate comments (3)
tests/components/plugwise/test_init.py (3)
399-400: Use safe dictionary access instead of direct indexing.Lines 399-400 use unsafe dictionary indexing on
DEFAULT_SCAN_INTERVAL[mock_smile_adam_heat_cool.smile.type]without a fallback. Ifsmile.typeisn't in the dictionary, this will raise aKeyError. Consider using.get()with a default value to match the pattern used in the coordinator.🔎 Proposed fix
- assert DEFAULT_SCAN_INTERVAL[mock_smile_adam_heat_cool.smile.type] == timedelta(seconds=60) - freezer.tick(DEFAULT_SCAN_INTERVAL[mock_smile_adam_heat_cool.smile.type]) + interval = DEFAULT_SCAN_INTERVAL.get(mock_smile_adam_heat_cool.smile.type, timedelta(seconds=60)) + assert interval == timedelta(seconds=60) + freezer.tick(interval)
417-417: Fix the docstring copy-paste error.The docstring says "Test Adam update interval" but this test is for the P1 gateway, not Adam.
🔎 Proposed fix
- """Test Adam update interval.""" + """Test P1 update interval."""
425-426: Use safe dictionary access instead of direct indexing.Lines 425-426 use unsafe dictionary indexing on
DEFAULT_SCAN_INTERVAL[mock_smile_p1.smile.type]without a fallback. Ifsmile.typeisn't in the dictionary, this will raise aKeyError. Consider using.get()with a default value to match the pattern used in the coordinator.🔎 Proposed fix
- assert DEFAULT_SCAN_INTERVAL[mock_smile_p1.smile.type] == timedelta(seconds=10) - freezer.tick(DEFAULT_SCAN_INTERVAL[mock_smile_p1.smile.type]) + interval = DEFAULT_SCAN_INTERVAL.get(mock_smile_p1.smile.type, timedelta(seconds=10)) + assert interval == timedelta(seconds=10) + freezer.tick(interval)
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/components/plugwise/test_init.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-23T16:26:34.700Z
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 906
File: tests/components/plugwise/test_binary_sensor.py:9-16
Timestamp: 2025-08-23T16:26:34.700Z
Learning: The Plugwise integration test files import utilities like `snapshot_platform`, `MockConfigEntry`, and `async_fire_time_changed` from `tests.common`, which is from the Home Assistant core repository at https://github.com/home-assistant/core/blob/master/tests/common.py, not from local test files.
Applied to files:
tests/components/plugwise/test_init.py
🧬 Code graph analysis (1)
tests/components/plugwise/test_init.py (1)
tests/components/plugwise/conftest.py (3)
mock_config_entry(81-95)mock_smile_adam_heat_cool(185-208)mock_smile_p1(295-317)
🪛 GitHub Actions: Test PR against HA-core
tests/components/plugwise/test_init.py
[error] 1-1: Pre-commit hook 'ruff' reported code changes and ultimately failed with exit code 1. 1 error fixed, 0 remaining. The hook modified the file (e.g., removal of an unused import: 'from homeassistant.setup import async_setup_component').
🔇 Additional comments (3)
tests/components/plugwise/test_init.py (3)
17-17: LGTM!The import of
DEFAULT_SCAN_INTERVALis correctly added and used in the new test cases.
159-159: LGTM!The migration from
async_setup_componenttohass.config_entries.async_setup(mock_config_entry.entry_id)is the correct approach for testing config entry-based integrations. This pattern is consistently applied across all affected tests.Also applies to: 284-284, 364-364
383-405: Well-structured test for update interval verification.The test correctly:
- Sets up the config entry and verifies the LOADED state
- Checks the initial update call count
- Uses
freezer.tick()to advance time by the expected interval- Triggers the coordinator update with
async_fire_time_changed- Verifies the second update call
ed0e836 to
f56ef94
Compare
1e4d7fe to
5b2f882
Compare
|



Also, replace all
async_setup_component()use.Summary by CodeRabbit
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.