|
18 | 18 | OscillationCommand, |
19 | 19 | WorkModeCommand, |
20 | 20 | ModeCommand, |
| 21 | + create_dreamview_command, |
21 | 22 | ) |
22 | 23 | from custom_components.govee.models.device import ( |
23 | 24 | CAPABILITY_ON_OFF, |
|
35 | 36 | INSTANCE_OSCILLATION, |
36 | 37 | INSTANCE_WORK_MODE, |
37 | 38 | INSTANCE_HDMI_SOURCE, |
| 39 | + INSTANCE_DREAMVIEW, |
38 | 40 | ) |
39 | 41 |
|
40 | 42 |
|
@@ -158,6 +160,21 @@ def test_is_hdmi_source(self): |
158 | 160 | assert cap.is_hdmi_source is True |
159 | 161 | assert cap.is_work_mode is False |
160 | 162 |
|
| 163 | + def test_is_dreamview(self): |
| 164 | + """Test DreamView toggle capability detection.""" |
| 165 | + cap = GoveeCapability( |
| 166 | + type=CAPABILITY_TOGGLE, |
| 167 | + instance=INSTANCE_DREAMVIEW, |
| 168 | + parameters={ |
| 169 | + "dataType": "ENUM", |
| 170 | + "options": [{"name": "on", "value": 1}, {"name": "off", "value": 0}], |
| 171 | + }, |
| 172 | + ) |
| 173 | + assert cap.is_dreamview is True |
| 174 | + assert cap.is_toggle is True |
| 175 | + assert cap.is_night_light is False |
| 176 | + assert cap.is_oscillation is False |
| 177 | + |
161 | 178 | def test_immutable(self): |
162 | 179 | """Test that GoveeCapability is immutable (frozen).""" |
163 | 180 | cap = GoveeCapability(type=CAPABILITY_ON_OFF, instance=INSTANCE_POWER, parameters={}) |
@@ -257,6 +274,14 @@ def test_get_hdmi_source_options_no_support(self, mock_light_device): |
257 | 274 | options = mock_light_device.get_hdmi_source_options() |
258 | 275 | assert options == [] |
259 | 276 |
|
| 277 | + def test_supports_dreamview(self, mock_dreamview_device): |
| 278 | + """Test DreamView support detection.""" |
| 279 | + assert mock_dreamview_device.supports_dreamview is True |
| 280 | + |
| 281 | + def test_no_dreamview_support(self, mock_light_device): |
| 282 | + """Test that regular lights don't have DreamView support.""" |
| 283 | + assert mock_light_device.supports_dreamview is False |
| 284 | + |
260 | 285 | def test_from_api_response(self, api_device_response): |
261 | 286 | """Test creating device from API response.""" |
262 | 287 | device = GoveeDevice.from_api_response(api_device_response) |
@@ -541,3 +566,22 @@ def test_mode_command_immutable(self): |
541 | 566 | cmd = ModeCommand(mode_instance="hdmiSource", value=1) |
542 | 567 | with pytest.raises(AttributeError): |
543 | 568 | cmd.value = 2 |
| 569 | + |
| 570 | + def test_dreamview_command_on(self): |
| 571 | + """Test create_dreamview_command for turning DreamView on.""" |
| 572 | + cmd = create_dreamview_command(enabled=True) |
| 573 | + assert cmd.toggle_instance == "dreamViewToggle" |
| 574 | + assert cmd.enabled is True |
| 575 | + assert cmd.get_value() == 1 |
| 576 | + payload = cmd.to_api_payload() |
| 577 | + assert payload["type"] == "devices.capabilities.toggle" |
| 578 | + assert payload["instance"] == "dreamViewToggle" |
| 579 | + assert payload["value"] == 1 |
| 580 | + |
| 581 | + def test_dreamview_command_off(self): |
| 582 | + """Test create_dreamview_command for turning DreamView off.""" |
| 583 | + cmd = create_dreamview_command(enabled=False) |
| 584 | + assert cmd.enabled is False |
| 585 | + assert cmd.get_value() == 0 |
| 586 | + payload = cmd.to_api_payload() |
| 587 | + assert payload["value"] == 0 |
0 commit comments