|
| 1 | +"""Tests for KOF.""" |
| 2 | +from unittest import mock |
| 3 | + |
| 4 | +import zigpy.device |
| 5 | +import zigpy.endpoint |
| 6 | +import zigpy.quirks |
| 7 | + |
| 8 | + |
| 9 | +def test_kof_no_reply(): |
| 10 | + """Test KOF No reply.""" |
| 11 | + |
| 12 | + class TestCluster(zigpy.quirks.kof.NoReplyMixin, zigpy.quirks.CustomCluster): |
| 13 | + """Test Cluster Class.""" |
| 14 | + |
| 15 | + cluster_id = 0x1234 |
| 16 | + void_input_commands = [0x0002] |
| 17 | + server_commands = { |
| 18 | + 0x0001: ("noop", (), False), |
| 19 | + 0x0002: ("noop_noreply", (), False), |
| 20 | + } |
| 21 | + client_commands = {} |
| 22 | + |
| 23 | + end_point = mock.MagicMock() |
| 24 | + cluster = TestCluster(end_point) |
| 25 | + |
| 26 | + cluster.command(0x0001) |
| 27 | + end_point.request.assert_called_with( |
| 28 | + mock.ANY, mock.ANY, mock.ANY, expect_reply=True, command_id=mock.ANY |
| 29 | + ) |
| 30 | + end_point.reset_mock() |
| 31 | + |
| 32 | + cluster.command(0x0001, expect_reply=False) |
| 33 | + end_point.request.assert_called_with( |
| 34 | + mock.ANY, mock.ANY, mock.ANY, expect_reply=False, command_id=mock.ANY |
| 35 | + ) |
| 36 | + end_point.reset_mock() |
| 37 | + |
| 38 | + cluster.command(0x0002) |
| 39 | + end_point.request.assert_called_with( |
| 40 | + mock.ANY, mock.ANY, mock.ANY, expect_reply=False, command_id=mock.ANY |
| 41 | + ) |
| 42 | + end_point.reset_mock() |
| 43 | + |
| 44 | + cluster.command(0x0002, expect_reply=True) |
| 45 | + end_point.request.assert_called_with( |
| 46 | + mock.ANY, mock.ANY, mock.ANY, expect_reply=True, command_id=mock.ANY |
| 47 | + ) |
| 48 | + end_point.reset_mock() |
0 commit comments