-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_sapi_srsp.py
executable file
·117 lines (83 loc) · 2.75 KB
/
test_sapi_srsp.py
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
#! /usr/bin/env python3
# test_sapi_srsp.py
#
# Unit tests for MT SAPI command response parsing
#
# Author: Rhodri James ([email protected])
# Date: 15 July 2016
#
# Copyright 2016 Kynesim Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import base_test
import unittest
class BaseSapiSRsp(base_test.BaseTest):
SUBSYSTEM = "SAPI"
TYPE = "SRSP"
class TestZbStartRequest(BaseSapiSRsp):
COMMAND = 0x00
COMMAND_NAME = "ZB_START_REQUEST"
def test_start(self):
self.run_test()
class TestZbPermitJoiningRequest(BaseSapiSRsp):
COMMAND = 0x08
COMMAND_NAME = "ZB_PERMIT_JOINING_REQUEST"
def test_permit_join(self):
self.add_byte("Status", "Success", 0)
self.run_test()
class TestZbBindDevice(BaseSapiSRsp):
COMMAND = 0x01
COMMAND_NAME = "ZB_BIND_DEVICE"
def test_bind(self):
self.run_test()
class TestZbAllowBind(BaseSapiSRsp):
COMMAND = 0x02
COMMAND_NAME = "ZB_ALLOW_BIND"
def test_allow_bind(self):
self.run_test()
class TestZbSendDataRequest(BaseSapiSRsp):
COMMAND = 0x03
COMMAND_NAME = "ZB_SEND_DATA_REQUEST"
def test_send_data(self):
self.run_test()
class TestZbReadConfiguration(BaseSapiSRsp):
COMMAND = 0x04
COMMAND_NAME = "ZB_READ_CONFIGURATION"
def test_read_config(self):
self.add_byte("Status", "Success", 0)
self.add_byte("ConfigId", "0x02")
self.add_byte("Length", "4")
self.add_bytes("Data", (0x05, 0x06, 0x07, 0x99))
self.run_test()
class TestZbWriteConfiguration(BaseSapiSRsp):
COMMAND = 0x05
COMMAND_NAME = "ZB_WRITE_CONFIGURATION"
def test_write_config(self):
self.add_byte("Status", "Failed", 1)
self.run_test()
class TestZbGetDeviceInfo(BaseSapiSRsp):
COMMAND = 0x06
COMMAND_NAME = "ZB_GET_DEVICE_INFO"
def test_get_info(self):
self.add_byte("Param", "0x42")
self.add_bytes("Value", (0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08),
leading_0x=True)
self.run_test()
class TestZbFindDeviceRequest(BaseSapiSRsp):
COMMAND = 0x07
COMMAND_NAME = "ZB_FIND_DEVICE_REQUEST"
def test_find_device(self):
self.run_test()
if __name__ == "__main__":
unittest.main()