Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow groupId to be a variable in YAML tests. #29641

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ def __init__(self, test: _TestStepWithPlaceholders, step_index: int, runtime_con
self._test.event)
self._test.endpoint = self._config_variable_substitution(
self._test.endpoint)
self._test.group_id = self._config_variable_substitution(
self._test.group_id)
test.update_arguments(self.arguments)
test.update_responses(self.responses)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __check_test_step(self, config: dict, content):
'identity': str,
'nodeId': int,
'runIf': str, # Should be a variable.
'groupId': int,
'groupId': (int, str), # Can be a variable.
'endpoint': (int, str), # Can be a variable
'cluster': str,
'attribute': str,
Expand Down
18 changes: 17 additions & 1 deletion scripts/py_matter_yamltests/test_yaml_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def test_key_tests_step_int_keys(self):
' - {key}: {value}')
keys = [
'nodeId',
'groupId',
'minInterval',
'maxInterval',
'timedInteractionTimeoutMs',
Expand Down Expand Up @@ -324,6 +323,23 @@ def test_key_tests_step_endpoint_number_key(self):
x = content.format(value=value)
self.assertRaises(TestStepInvalidTypeError, load, x)

def test_key_tests_step_group_id_key(self):
load = YamlLoader().load

content = ('tests:\n'
' - groupId: {value}')

_, _, _, _, tests = load(content.format(value=1))
self.assertEqual(tests, [{'groupId': 1}])

_, _, _, _, tests = load(content.format(value='TestKey'))
self.assertEqual(tests, [{'groupId': 'TestKey'}])

wrong_values = self._get_wrong_values([str, int], spaces=6)
for value in wrong_values:
x = content.format(value=value)
self.assertRaises(TestStepInvalidTypeError, load, x)

def test_key_tests_step_event_number_key(self):
load = YamlLoader().load

Expand Down
6 changes: 5 additions & 1 deletion src/app/tests/suites/TestGroupMessaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ config:
nodeId: 0x12344321
cluster: "Basic Information"
endpoint: 0
# Test that a group id can be a variable.
groupIdVariable:
type: int16u
defaultValue: 0x0101
nodeId2:
type: node_id
defaultValue: 0x43211234
Expand Down Expand Up @@ -215,7 +219,7 @@ tests:
- label: "Turn On the light to see attribute change"
cluster: "On/Off"
command: "On"
groupId: 0x0101
groupId: groupIdVariable # 0x0101

# Give the group invoke time to actually happen; unicast delivery can outrace
# multicast if the unicast packet is sent immediately after the multicast one.
Expand Down