From dccceb9edb385732a8e25d8762dd05afde5a59c1 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Thu, 23 Mar 2023 06:49:46 +0100 Subject: [PATCH] Add test to confirm that power config isn't bound --- tests/test_tuya.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_tuya.py b/tests/test_tuya.py index bcbcb48283..01440bf1c9 100644 --- a/tests/test_tuya.py +++ b/tests/test_tuya.py @@ -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 ( @@ -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 @@ -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