Skip to content

Commit

Permalink
Merge pull request #125 from bdraco/add_test_coverage_for_rgbww_bulbs
Browse files Browse the repository at this point in the history
Add test coverage for RGBWW bulbs
  • Loading branch information
sbidy authored Feb 13, 2022
2 parents ed71ae3 + d5b3f20 commit ee9f097
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 9 deletions.
36 changes: 33 additions & 3 deletions pywizlight/tests/fake_bulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pywizlight.protocol import WizProtocol

MODULE_CONFIGS = {
MODULE_CONFIGS = { # AKA getModelConfig
("ESP01_SHRGB_03", "1.25.0"): {
"method": "getModelConfig",
"env": "pro",
Expand Down Expand Up @@ -116,7 +116,7 @@
},
}

SYSTEM_CONFIGS = {
SYSTEM_CONFIGS = { # AKA getSystemConfig
("ESP01_SHRGB_03", "1.25.0"): {
"method": "getSystemConfig",
"env": "pro",
Expand Down Expand Up @@ -284,9 +284,25 @@
"ping": 0,
},
},
("ESP01_SHRGB1C_31", "1.17.1"): {
"method": "getSystemConfig",
"env": "pro",
"result": {
"mac": "a8bb50bdf8d7",
"homeId": 5385975,
"roomId": 0,
"homeLock": False,
"pairingLock": False,
"typeId": 0,
"moduleName": "ESP01_SHRGB1C_31",
"fwVersion": "1.17.1",
"groupId": 0,
"drvConf": [20, 2],
},
},
}

USER_CONFIGS = {
USER_CONFIGS = { # AKA getUserConfig
("ESP20_SHRGB_01ABI", "1.21.4"): {
"method": "getUserConfig",
"env": "pro",
Expand Down Expand Up @@ -330,6 +346,20 @@
"po": True,
},
},
("ESP01_SHRGB1C_31", "1.17.1"): {
"method": "getUserConfig",
"env": "pro",
"result": {
"fadeIn": 450,
"fadeOut": 500,
"fadeNight": False,
"dftDim": 100,
"pwmRange": [0, 100],
"whiteRange": [2700, 6500],
"extRange": [2700, 6500],
"po": False,
},
},
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@pytest.fixture()
async def rgbtw_bulb() -> AsyncGenerator[wizlight, None]:
async def rgbw_bulb() -> AsyncGenerator[wizlight, None]:
shutdown, port = await startup_bulb(
module_name="ESP20_SHRGBC_01", firmware_version="1.21.4"
)
Expand All @@ -20,9 +20,9 @@ async def rgbtw_bulb() -> AsyncGenerator[wizlight, None]:


@pytest.mark.asyncio
async def test_model_description_dimmable_bulb(rgbtw_bulb: wizlight) -> None:
"""Test fetching the model description dimmable bulb."""
bulb_type = await rgbtw_bulb.get_bulbtype()
async def test_model_description_rgbw_bulb(rgbw_bulb: wizlight) -> None:
"""Test fetching the model description rgbw bulb."""
bulb_type = await rgbw_bulb.get_bulbtype()
assert bulb_type == BulbType(
features=Features(color=True, color_tmp=True, effect=True, brightness=True),
name="ESP20_SHRGBC_01",
Expand All @@ -35,9 +35,9 @@ async def test_model_description_dimmable_bulb(rgbtw_bulb: wizlight) -> None:


@pytest.mark.asyncio
async def test_supported_scenes(rgbtw_bulb: wizlight) -> None:
async def test_supported_scenes(rgbw_bulb: wizlight) -> None:
"""Test supported scenes."""
assert await rgbtw_bulb.getSupportedScenes() == [
assert await rgbw_bulb.getSupportedScenes() == [
"Ocean",
"Romance",
"Sunset",
Expand Down
34 changes: 34 additions & 0 deletions pywizlight/tests/test_bulb_rgbww_1_17_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Tests for the Bulb API."""
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 rgbww_bulb() -> AsyncGenerator[wizlight, None]:
shutdown, port = await startup_bulb(
module_name="ESP01_SHRGB1C_31", firmware_version="1.17.1"
)
bulb = wizlight(ip="127.0.0.1", port=port)
yield bulb
await bulb.async_close()
shutdown()


@pytest.mark.asyncio
async def test_model_description_rgbww_bulb(rgbww_bulb: wizlight) -> None:
"""Test fetching the model description rgbww bulb."""
bulb_type = await rgbww_bulb.get_bulbtype()
assert bulb_type == BulbType(
features=Features(color=True, color_tmp=True, effect=True, brightness=True),
name="ESP01_SHRGB1C_31",
kelvin_range=KelvinRange(max=6500, min=2700),
bulb_type=BulbClass.RGB,
fw_version="1.17.1",
white_channels=2,
white_to_color_ratio=20,
)

0 comments on commit ee9f097

Please sign in to comment.