GeezerVison is showing github.com — Mock is_on instead of mutating _info in light_effect tests · python-kasa/python-kasa@f04f085
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: tests/smart/modules/test_light_effect.py +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,9 +67,14 @@ async def test_light_effect_brightness( |
67 | 67 | if effect_active: # Set the rule L1 active for testing |
68 | 68 | light_effect.data["current_rule_id"] = "L1" |
69 | 69 |
|
70 | | - # Force device_on so the asserted payload is deterministic across fixtures |
| 70 | + # Force is_on=True so the asserted payload is deterministic across fixtures |
71 | 71 | # (some fixtures' get_device_info has device_on: false). |
72 | | - dev._info["device_on"] = True |
| 72 | + mocker.patch.object( |
| 73 | + type(dev), |
| 74 | + "is_on", |
| 75 | + new_callable=mocker.PropertyMock, |
| 76 | + return_value=True, |
| 77 | + ) |
73 | 78 |
|
74 | 79 | await light_module.set_brightness(10) |
75 | 80 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: tests/smart/modules/test_light_strip_effect.py +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -82,9 +82,14 @@ async def test_light_effect_brightness( |
82 | 82 | return_value=effect_active, |
83 | 83 | ) |
84 | 84 |
|
85 | | - # Force device_on so the asserted payload is deterministic across fixtures |
| 85 | + # Force is_on=True so the asserted payload is deterministic across fixtures |
86 | 86 | # (some fixtures' get_device_info has device_on: false). |
87 | | - dev._info["device_on"] = True |
| 87 | + mocker.patch.object( |
| 88 | + type(dev), |
| 89 | + "is_on", |
| 90 | + new_callable=mocker.PropertyMock, |
| 91 | + return_value=True, |
| 92 | + ) |
88 | 93 |
|
89 | 94 | await light_module.set_brightness(10) |
90 | 95 |
|
|