-
Notifications
You must be signed in to change notification settings - Fork 531
Expand file tree
/
Copy pathtest_multiir_contact_tamper.lua
More file actions
executable file
·167 lines (154 loc) · 4.92 KB
/
test_multiir_contact_tamper.lua
File metadata and controls
executable file
·167 lines (154 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0
local test = require "integration_test"
local clusters = require "st.zigbee.zcl.clusters"
local capabilities = require "st.capabilities"
local t_utils = require "integration_test.utils"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local IASZone = clusters.IASZone
local PowerConfiguration = clusters.PowerConfiguration
local mock_device = test.mock_device.build_test_zigbee_device(
{ profile = t_utils.get_profile_definition("contact-battery-tamper-profile.yml"),
zigbee_endpoints = {
[0x01] = {
id = 0x01,
manufacturer = "MultIR",
model = "MIR-MC100",
server_clusters = { 0x0001,0x0003, 0x0005, 0x0006 }
}
}
}
)
zigbee_test_utils.prepare_zigbee_env_info()
local function test_init()
test.mock_device.add_test_device(mock_device)
end
test.set_test_init_function(test_init)
test.register_coroutine_test(
"Handle added lifecycle",
function()
test.socket.zigbee:__set_channel_ordering("relaxed")
test.socket.capability:__set_channel_ordering("relaxed")
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
capabilities.battery.battery(100)))
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
capabilities.contactSensor.contact.closed()))
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
capabilities.tamperAlert.tamper.clear()))
end,
{
min_api_version = 19
}
)
test.register_coroutine_test(
"Handle doConfigure lifecycle",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, PowerConfiguration.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
PowerConfiguration.attributes.BatteryPercentageRemaining:configure_reporting(mock_device, 0x001e, 0x5460, 1)
})
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end,
{
min_api_version = 19
}
)
test.register_message_test(
"Reported ZoneStatus should be handled: contact/closed tamper/clear",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, IASZone.attributes.ZoneStatus:build_test_attr_report(mock_device, 0x0000) }
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.closed())
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.tamperAlert.tamper.clear())
}
},
{
min_api_version = 19
}
)
test.register_message_test(
"Reported ZoneStatus should be handled: contact/open tamper/detected",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, IASZone.attributes.ZoneStatus:build_test_attr_report(mock_device, 0x0005) }
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.open())
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.tamperAlert.tamper.detected())
}
},
{
min_api_version = 19
}
)
test.register_message_test(
"ZoneStatusChangeNotification should be handled: contact/open tamper/detected",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, IASZone.client.commands.ZoneStatusChangeNotification.build_test_rx(mock_device, 0x0005, 0x00) }
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.open())
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.tamperAlert.tamper.detected())
}
},
{
min_api_version = 19
}
)
test.register_message_test(
"ZoneStatusChangeNotification should be handled: contact/closed tamper/clear",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, IASZone.client.commands.ZoneStatusChangeNotification.build_test_rx(mock_device, 0x0000, 0x00) }
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.closed())
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.tamperAlert.tamper.clear())
}
},
{
min_api_version = 19
}
)
test.run_registered_tests()