-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reporting available scenes on RGB devices
- Add coverage for scenes
- Loading branch information
Showing
9 changed files
with
264 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,72 @@ | ||
"""Tests for the Bulb API with a rgbtw bulb.""" | ||
from typing import AsyncGenerator | ||
|
||
import pytest | ||
|
||
from pywizlight import wizlight | ||
from pywizlight.bulblibrary import BulbClass, BulbType, Features, KelvinRange | ||
from pywizlight.tests.fake_bulb import startup_bulb | ||
|
||
|
||
@pytest.fixture() | ||
async def dimmable_bulb() -> AsyncGenerator[wizlight, None]: | ||
shutdown = startup_bulb(module_name="ESP20_SHRGBC_01", firmware_version="1.21.4") | ||
bulb = wizlight(ip="127.0.0.1") | ||
yield bulb | ||
await bulb.async_close() | ||
shutdown() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_model_description_dimmable_bulb(dimmable_bulb: wizlight) -> None: | ||
"""Test fetching the model description dimmable bulb.""" | ||
bulb_type = await dimmable_bulb.get_bulbtype() | ||
assert bulb_type == BulbType( | ||
features=Features(color=True, color_tmp=True, effect=True, brightness=True), | ||
name="ESP20_SHRGBC_01", | ||
kelvin_range=KelvinRange(max=6500, min=2200), | ||
bulb_type=BulbClass.RGB, | ||
fw_version="1.21.4", | ||
white_channels=1, | ||
white_to_color_ratio=30, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_supported_scenes(dimmable_bulb: wizlight) -> None: | ||
"""Test supported scenes.""" | ||
assert await dimmable_bulb.getSupportedScenes() == [ | ||
"Ocean", | ||
"Romance", | ||
"Sunset", | ||
"Party", | ||
"Fireplace", | ||
"Cozy", | ||
"Forest", | ||
"Pastel Colors", | ||
"Wake up", | ||
"Bedtime", | ||
"Warm White", | ||
"Daylight", | ||
"Cool white", | ||
"Night light", | ||
"Focus", | ||
"Relax", | ||
"True colors", | ||
"TV time", | ||
"Plantgrowth", | ||
"Spring", | ||
"Summer", | ||
"Fall", | ||
"Deepdive", | ||
"Jungle", | ||
"Mojito", | ||
"Club", | ||
"Christmas", | ||
"Halloween", | ||
"Candlelight", | ||
"Golden white", | ||
"Pulse", | ||
"Steampunk", | ||
"Rhythm", | ||
] |
This file contains 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 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,53 @@ | ||
"""Tests for the Bulb API with a light strip.""" | ||
from typing import AsyncGenerator | ||
|
||
import pytest | ||
|
||
from pywizlight import wizlight | ||
from pywizlight.bulblibrary import BulbClass, BulbType, Features, KelvinRange | ||
from pywizlight.tests.fake_bulb import startup_bulb | ||
|
||
|
||
@pytest.fixture() | ||
async def turnable_bulb() -> AsyncGenerator[wizlight, None]: | ||
shutdown = startup_bulb(module_name="ESP21_SHTW_01", firmware_version="1.25.0") | ||
bulb = wizlight(ip="127.0.0.1") | ||
yield bulb | ||
await bulb.async_close() | ||
shutdown() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_model_description_dimmable_bulb(turnable_bulb: wizlight) -> None: | ||
"""Test fetching the model description dimmable bulb.""" | ||
bulb_type = await turnable_bulb.get_bulbtype() | ||
assert bulb_type == BulbType( | ||
features=Features(color=False, color_tmp=True, effect=True, brightness=True), | ||
name="ESP21_SHTW_01", | ||
kelvin_range=KelvinRange(max=5000, min=2700), | ||
bulb_type=BulbClass.TW, | ||
fw_version="1.25.0", | ||
white_channels=1, | ||
white_to_color_ratio=20, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_supported_scenes(turnable_bulb: wizlight) -> None: | ||
"""Test supported scenes.""" | ||
assert await turnable_bulb.getSupportedScenes() == [ | ||
"Cozy", | ||
"Wake up", | ||
"Bedtime", | ||
"Warm White", | ||
"Daylight", | ||
"Cool white", | ||
"Night light", | ||
"Focus", | ||
"Relax", | ||
"TV time", | ||
"Candlelight", | ||
"Golden white", | ||
"Pulse", | ||
"Steampunk", | ||
] |