-
Notifications
You must be signed in to change notification settings - Fork 21
fix: include superQuiet in 3-speed unit fan_speeds #73
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
Merged
dlarrick
merged 3 commits into
dlarrick:master
from
d-walsh:fix-3speed-superquiet-missing
Jun 15, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """Tests for get_fan_speeds() across all numberOfFanSpeeds values.""" | ||
|
|
||
| import unittest | ||
| from unittest.mock import patch | ||
| from pykumo.py_kumo import PyKumo | ||
|
|
||
|
|
||
| def make_unit(num_speeds, has_auto=False): | ||
| """Return a minimally-mocked PyKumo with the given profile.""" | ||
| with patch.object(PyKumo, "__init__", lambda self, *a, **kw: None): | ||
| unit = PyKumo.__new__(PyKumo) | ||
| profile = {"numberOfFanSpeeds": num_speeds} | ||
| if has_auto: | ||
| profile["hasFanSpeedAuto"] = True | ||
| unit._profile = profile | ||
| unit._status = {} | ||
| return unit | ||
|
|
||
|
|
||
| class TestGetFanSpeeds(unittest.TestCase): | ||
| def test_3speed_full_set(self): | ||
| """Units reporting numberOfFanSpeeds=3 expose the full 5-speed set.""" | ||
| unit = make_unit(3) | ||
| speeds = unit.get_fan_speeds() | ||
| self.assertEqual( | ||
| speeds, | ||
| ["superQuiet", "quiet", "low", "powerful", "superPowerful"], | ||
| ) | ||
|
|
||
| def test_3speed_superquiet_is_first(self): | ||
| """superQuiet should be the first option for 3-speed units.""" | ||
| unit = make_unit(3) | ||
| speeds = unit.get_fan_speeds() | ||
| self.assertEqual(speeds[0], "superQuiet") | ||
|
|
||
| def test_3speed_superpowerful_is_last_before_auto(self): | ||
| """superPowerful should be the last non-auto option for 3-speed units.""" | ||
| unit = make_unit(3) | ||
| speeds = unit.get_fan_speeds() | ||
| self.assertEqual(speeds[-1], "superPowerful") | ||
|
|
||
| def test_3speed_with_auto(self): | ||
| """3-speed + hasFanSpeedAuto appends auto at end.""" | ||
| unit = make_unit(3, has_auto=True) | ||
| speeds = unit.get_fan_speeds() | ||
| self.assertEqual( | ||
| speeds, | ||
| ["superQuiet", "quiet", "low", "powerful", "superPowerful", "auto"], | ||
| ) | ||
|
|
||
| def test_4speed_unchanged(self): | ||
| """4-speed behaviour is unchanged.""" | ||
| unit = make_unit(4) | ||
| speeds = unit.get_fan_speeds() | ||
| self.assertEqual(speeds, ["quiet", "Low", "powerful", "superPowerful"]) | ||
|
|
||
| def test_5speed_unchanged(self): | ||
| """5-speed (default) behaviour is unchanged.""" | ||
| unit = make_unit(5) | ||
| speeds = unit.get_fan_speeds() | ||
| self.assertEqual( | ||
| speeds, ["superQuiet", "quiet", "low", "powerful", "superPowerful"] | ||
| ) | ||
|
|
||
| def test_set_fan_speed_accepts_superquiet_on_3speed(self): | ||
| """set_fan_speed must accept superQuiet for 3-speed units.""" | ||
| with patch.object(PyKumo, "__init__", lambda self, *a, **kw: None): | ||
| unit = PyKumo.__new__(PyKumo) | ||
| unit._profile = {"numberOfFanSpeeds": 3} | ||
| unit._status = {} | ||
| valid = unit.get_fan_speeds() | ||
| self.assertIn("superQuiet", valid) | ||
|
|
||
| def test_set_fan_speed_accepts_superpowerful_on_3speed(self): | ||
| """set_fan_speed must accept superPowerful for 3-speed units.""" | ||
| with patch.object(PyKumo, "__init__", lambda self, *a, **kw: None): | ||
| unit = PyKumo.__new__(PyKumo) | ||
| unit._profile = {"numberOfFanSpeeds": 3} | ||
| unit._status = {} | ||
| valid = unit.get_fan_speeds() | ||
| self.assertIn("superPowerful", valid) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot has a point here but I think the solution is to rename these tests |
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
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.
Uh oh!
There was an error while loading. Please reload this page.