|
| 1 | +-- Copyright 2025 SmartThings |
| 2 | +-- |
| 3 | +-- Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +-- you may not use this file except in compliance with the License. |
| 5 | +-- You may obtain a copy of the License at |
| 6 | +-- |
| 7 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +-- |
| 9 | +-- Unless required by applicable law or agreed to in writing, software |
| 10 | +-- distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +-- See the License for the specific language governing permissions and |
| 13 | +-- limitations under the License. |
| 14 | + |
| 15 | +local test = require "integration_test" |
| 16 | +local t_utils = require "integration_test.utils" |
| 17 | +local dkjson = require 'dkjson' |
| 18 | + |
| 19 | +-- This test attempts to add a zwave device to this zigbee switch driver |
| 20 | +-- Once the monkey-patch is removed with hubcore 59 is released with: |
| 21 | +-- https://smartthings.atlassian.net/browse/CHAD-16552 |
| 22 | +local mock_device = test.mock_device.build_test_zwave_device({ |
| 23 | + profile = t_utils.get_profile_definition("on-off-level.yml"), |
| 24 | +}) |
| 25 | + |
| 26 | +local function test_init() |
| 27 | + test.mock_device.add_test_device(mock_device) |
| 28 | +end |
| 29 | + |
| 30 | +test.set_test_init_function(test_init) |
| 31 | + |
| 32 | +-- Just validating that the driver doesn't crash is enough to validate |
| 33 | +-- that the work-around is effective in ignoring the incorrect device kind |
| 34 | +test.register_coroutine_test("zwave_device_handled", function() |
| 35 | + test.mock_device.add_test_device(mock_device) |
| 36 | + test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" }) |
| 37 | + test.wait_for_events() |
| 38 | + test.socket.device_lifecycle:__queue_receive({ mock_device.id, "init" }) |
| 39 | + test.wait_for_events() |
| 40 | + test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" }) |
| 41 | + mock_device:expect_metadata_update({provisioning_state = "PROVISIONED"}) |
| 42 | + test.wait_for_events() |
| 43 | + test.socket.device_lifecycle:__queue_receive({ mock_device.id, "infoChanged", dkjson.encode(mock_device.raw_st_data) }) |
| 44 | + test.wait_for_events() |
| 45 | + end, |
| 46 | + nil |
| 47 | +) |
| 48 | + |
| 49 | +test.register_message_test( |
| 50 | + "Capability command for incorrect protocol", |
| 51 | + { |
| 52 | + channel = "capability", |
| 53 | + direction = "receive", |
| 54 | + message = { mock_device.id, { capability = "switch", component = "main", command = "on", args = { } } } |
| 55 | + } |
| 56 | +) |
| 57 | + |
| 58 | +test.run_registered_tests() |
0 commit comments