Skip to content

Commit

Permalink
Merge pull request #138 from bdraco/old_socket_firmware
Browse files Browse the repository at this point in the history
Add tests for older socket firmware
  • Loading branch information
sbidy authored Feb 22, 2022
2 parents f6fa5a6 + 64d94e2 commit 81e3f32
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pywizlight/tests/fake_bulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@
"ping": 0,
},
},
("ESP10_SOCKET_06", "1.16.71"): {
"method": "getSystemConfig",
"env": "pro",
"result": {
"mac": "a8bb50df7693",
"homeId": 5385975,
"roomId": 8201410,
"homeLock": False,
"pairingLock": False,
"typeId": 0,
"moduleName": "ESP10_SOCKET_06",
"fwVersion": "1.16.71",
"groupId": 0,
"drvConf": [20, 2],
},
},
("ESP05_SHDW_21", "1.25.0"): {
"method": "getSystemConfig",
"env": "pro",
Expand Down Expand Up @@ -503,6 +519,20 @@
},
},
("BROKEN_JSON", "1.0.0"): json.JSONDecodeError,
("ESP10_SOCKET_06", "1.16.71"): {
"method": "getUserConfig",
"env": "pro",
"result": {
"fadeIn": 450,
"fadeOut": 500,
"fadeNight": False,
"dftDim": 100,
"pwmRange": [0, 100],
"whiteRange": [2700, 6500],
"extRange": [2700, 6500],
"po": False,
},
},
}

MODEL_CONFIG_NOT_FOUND = {
Expand Down
40 changes: 40 additions & 0 deletions pywizlight/tests/test_bulb_socket_1_16_71.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Tests for the Bulb API with a socket."""
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 socket() -> AsyncGenerator[wizlight, None]:
shutdown, port = await startup_bulb(
module_name="ESP10_SOCKET_06", firmware_version="1.16.71"
)
bulb = wizlight(ip="127.0.0.1", port=port)
yield bulb
await bulb.async_close()
shutdown()


@pytest.mark.asyncio
async def test_model_description_socket(socket: wizlight) -> None:
"""Test fetching the model description of a socket is None."""
bulb_type = await socket.get_bulbtype()
assert bulb_type == BulbType(
features=Features(
color=False,
color_tmp=False,
effect=False,
brightness=False,
dual_head=False,
),
name="ESP10_SOCKET_06",
kelvin_range=KelvinRange(max=6500, min=2700),
bulb_type=BulbClass.SOCKET,
fw_version="1.16.71",
white_channels=2,
white_to_color_ratio=20,
)

0 comments on commit 81e3f32

Please sign in to comment.