From d5b3f20e16a072eac222ecdae658aaeebbb4afcb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 12 Feb 2022 18:36:49 -0600 Subject: [PATCH] Add test coverage for RGBWW bulbs --- pywizlight/tests/fake_bulb.py | 36 +++++++++++++++++-- ...btw_1_21_4.py => test_bulb_rgbw_1_21_4.py} | 12 +++---- pywizlight/tests/test_bulb_rgbww_1_17_1.py | 34 ++++++++++++++++++ 3 files changed, 73 insertions(+), 9 deletions(-) rename pywizlight/tests/{test_bulb_rgbtw_1_21_4.py => test_bulb_rgbw_1_21_4.py} (81%) create mode 100644 pywizlight/tests/test_bulb_rgbww_1_17_1.py diff --git a/pywizlight/tests/fake_bulb.py b/pywizlight/tests/fake_bulb.py index 654128f..6989753 100644 --- a/pywizlight/tests/fake_bulb.py +++ b/pywizlight/tests/fake_bulb.py @@ -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", @@ -116,7 +116,7 @@ }, } -SYSTEM_CONFIGS = { +SYSTEM_CONFIGS = { # AKA getSystemConfig ("ESP01_SHRGB_03", "1.25.0"): { "method": "getSystemConfig", "env": "pro", @@ -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", @@ -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, + }, + }, } diff --git a/pywizlight/tests/test_bulb_rgbtw_1_21_4.py b/pywizlight/tests/test_bulb_rgbw_1_21_4.py similarity index 81% rename from pywizlight/tests/test_bulb_rgbtw_1_21_4.py rename to pywizlight/tests/test_bulb_rgbw_1_21_4.py index 94e4c7c..026141a 100644 --- a/pywizlight/tests/test_bulb_rgbtw_1_21_4.py +++ b/pywizlight/tests/test_bulb_rgbw_1_21_4.py @@ -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" ) @@ -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", @@ -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", diff --git a/pywizlight/tests/test_bulb_rgbww_1_17_1.py b/pywizlight/tests/test_bulb_rgbww_1_17_1.py new file mode 100644 index 0000000..deb54bb --- /dev/null +++ b/pywizlight/tests/test_bulb_rgbww_1_17_1.py @@ -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, + )