-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chiptool.py] Add some mechanism to add additional custom pseudo clus…
…ters by using a custom folder
- Loading branch information
1 parent
bfa0580
commit c6ed941
Showing
7 changed files
with
186 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
|
||
from matter_yamltests.pseudo_clusters.pseudo_cluster import PseudoCluster | ||
|
||
|
||
class example_cluster(PseudoCluster): | ||
name = 'ExampleCluster' | ||
|
||
async def CommandSuccess(self, request): | ||
return {} | ||
|
||
async def CommandError(self, request): | ||
return {'error': 'UNSUPPORTED_COMMAND'} | ||
|
||
async def CommandWithReturnValues(self, request): | ||
rv = { | ||
'BooleanTrue': True, | ||
'BooleanFalse': False, | ||
'PositiveNumber': 123456789, | ||
'NegativeNumber': -123456789, | ||
'ListOfBoolean': [True, False, True], | ||
'Struct': { | ||
'boolean': True, | ||
'number': 1, | ||
'struct': { | ||
'boolean': False, | ||
'number': 2, | ||
}, | ||
'list': [ | ||
{ | ||
'boolean': True, | ||
'number': 1, | ||
}, | ||
{ | ||
'boolean': False, | ||
'number': 3, | ||
}, | ||
] | ||
} | ||
} | ||
return {'value': rv} | ||
|
||
async def CommandWithInputValues(self, request): | ||
try: | ||
arg1 = int(self._get_argument_value(request, 'Argument1')) | ||
arg2 = int(self._get_argument_value(request, 'Argument2')) | ||
except NameError: | ||
return {'error': 'INVALID_COMMAND'} | ||
|
||
rv = {'ReturnValue': arg1 + arg2} | ||
return {'value': rv} | ||
|
||
def _get_argument_value(self, request, name): | ||
for argument in request.arguments['values']: | ||
if argument['name'] == name: | ||
return argument['value'] | ||
|
||
raise NameError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
name: Example Cluster Tests | ||
|
||
config: | ||
cluster: "ExampleCluster" | ||
|
||
tests: | ||
- label: "Call a command that returns a success" | ||
command: "CommandSuccess" | ||
|
||
- label: "Call a command that returns an error" | ||
command: "CommandError" | ||
response: | ||
error: UNSUPPORTED_COMMAND | ||
|
||
- label: "Call a command with some return values" | ||
command: "CommandWithReturnValues" | ||
response: | ||
values: | ||
- name: "BooleanTrue" | ||
value: true | ||
- name: "BooleanFalse" | ||
value: false | ||
- name: "PositiveNumber" | ||
value: 123456789 | ||
- name: "NegativeNumber" | ||
value: -123456789 | ||
- name: "ListOfBoolean" | ||
value: [true, false, true] | ||
- name: "Struct" | ||
value: | ||
{ | ||
"boolean": true, | ||
"number": 1, | ||
"struct": { "boolean": false, "number": 2 }, | ||
"list": | ||
[ | ||
{ "boolean": true, "number": 1 }, | ||
{ "boolean": false, "number": 3 }, | ||
], | ||
} | ||
|
||
- label: "Call a command with some input values" | ||
command: "CommandWithInputValues" | ||
arguments: | ||
values: | ||
- name: "Argument1" | ||
value: 123 | ||
- name: "Argument2" | ||
value: 456 | ||
response: | ||
- values: | ||
- name: "ReturnValue" | ||
value: 579 | ||
|
||
- label: | ||
"Call a command with some input values but expect a failure this time | ||
because some argument is missing" | ||
command: "CommandWithInputValues" | ||
arguments: | ||
values: | ||
- name: "Argument1" | ||
value: 123 | ||
response: | ||
error: INVALID_COMMAND |