Skip to content

Commit

Permalink
Add test to confirm that power config isn't bound
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJulianJES committed Mar 23, 2023
1 parent ccd163f commit dccceb9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_tuya.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from zigpy.quirks import CustomDevice, get_device
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import PowerConfiguration

import zhaquirks
from zhaquirks.const import (
Expand All @@ -23,6 +24,7 @@
ZONE_STATE,
)
from zhaquirks.tuya import Data, TuyaManufClusterAttributes, TuyaNewManufCluster
import zhaquirks.tuya.ts0041
import zhaquirks.tuya.ts0042
import zhaquirks.tuya.ts0043
import zhaquirks.tuya.ts0501_fan_switch
Expand Down Expand Up @@ -1527,3 +1529,31 @@ async def test_fan_switch_writes_attributes(zigpy_device_from_quirk, quirk):
1,
b"\x00\x01\x02\x01\x000\x00",
)


@pytest.mark.parametrize(
"quirk",
(zhaquirks.tuya.ts0041.TuyaSmartRemote0041TOPlusA,),
)
async def test_power_config_no_bind(zigpy_device_from_quirk, quirk):
"""Test that the power configuration cluster is not bound and no attribute reporting is set up."""

device = zigpy_device_from_quirk(quirk)
power_cluster = device.endpoints[1].power

request_patch = mock.patch("zigpy.zcl.Cluster.request", mock.AsyncMock())
bind_patch = mock.patch("zigpy.zcl.Cluster.bind", mock.AsyncMock())

with request_patch as request_mock, bind_patch as bind_mock:
request_mock.return_value = (foundation.Status.SUCCESS, "done")

await power_cluster.bind()
await power_cluster.configure_reporting(
PowerConfiguration.attributes_by_name["battery_percentage_remaining"].id,
3600,
10800,
1,
)

assert len(request_mock.mock_calls) == 0
assert len(bind_mock.mock_calls) == 0

0 comments on commit dccceb9

Please sign in to comment.