Skip to content

Commit

Permalink
[matter_yamltests] Allow endpoint, cluster, command, attribute, event…
Browse files Browse the repository at this point in the history
… to use a variable (#26678)
  • Loading branch information
vivien-apple authored and pull[bot] committed Feb 2, 2024
1 parent 54232a4 commit 341e169
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 187 deletions.
10 changes: 10 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ def __init__(self, test: _TestStepWithPlaceholders, step_index: int, runtime_con
self._test.run_if)
self._test.event_number = self._config_variable_substitution(
self._test.event_number)
self._test.cluster = self._config_variable_substitution(
self._test.cluster)
self._test.command = self._config_variable_substitution(
self._test.command)
self._test.attribute = self._config_variable_substitution(
self._test.attribute)
self._test.event = self._config_variable_substitution(
self._test.event)
self._test.endpoint = self._config_variable_substitution(
self._test.endpoint)
test.update_arguments(self.arguments)
test.update_responses(self.responses)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __check_test_step(self, content):
'nodeId': int,
'runIf': str, # Should be a variable.
'groupId': int,
'endpoint': int,
'endpoint': (int, str), # Can be a variable
'cluster': str,
'attribute': str,
'command': 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 @@ -249,7 +249,6 @@ def test_key_tests_step_int_keys(self):
keys = [
'nodeId',
'groupId',
'endpoint',
'minInterval',
'maxInterval',
'timedInteractionTimeoutMs',
Expand Down Expand Up @@ -307,6 +306,23 @@ def test_key_tests_step_response_key(self):
x = content.format(value=value)
self.assertRaises(TestStepInvalidTypeError, load, x)

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

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

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

_, _, _, _, tests = load(content.format(value='TestKey'))
self.assertEqual(tests, [{'endpoint': '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
16 changes: 8 additions & 8 deletions src/app/tests/suites/certification/Test_TC_DGETH_2_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,35 +136,35 @@ tests:
command: "readAttribute"
attribute: "PacketRxCount"
response:
saveAs: PacketRxCount
saveAs: PacketRxCountValue

- label: "TH reads PacketTxCount attribute value from DUT"
PICS: DGETH.S.A0003
command: "readAttribute"
attribute: "PacketTxCount"
response:
saveAs: PacketTxCount
saveAs: PacketTxCountValue

- label: "TH reads TxErrCount attribute value from DUT"
PICS: DGETH.S.A0004
command: "readAttribute"
attribute: "TxErrCount"
response:
saveAs: TxErrCount
saveAs: TxErrCountValue

- label: "TH reads CollisionCount attribute value from DUT"
PICS: DGETH.S.A0005
command: "readAttribute"
attribute: "CollisionCount"
response:
saveAs: CollisionCount
saveAs: CollisionCountValue

- label: "TH reads OverrunCount attribute value from DUT"
PICS: DGETH.S.A0006
command: "readAttribute"
attribute: "OverrunCount"
response:
saveAs: OverrunCount
saveAs: OverrunCountValue

#issue #13648
- label: "Sends ResetCounts command"
Expand Down Expand Up @@ -215,20 +215,20 @@ tests:
attribute: "TxErrCount"
response:
constraints:
maxValue: TxErrCount
maxValue: TxErrCountValue

- label: "TH reads CollisionCount attribute value from DUT"
PICS: DGETH.S.A0005
command: "readAttribute"
attribute: "CollisionCount"
response:
constraints:
maxValue: CollisionCount
maxValue: CollisionCountValue

- label: "TH reads OverrunCount attribute value from DUT"
PICS: DGETH.S.A0006
command: "readAttribute"
attribute: "OverrunCount"
response:
constraints:
maxValue: OverrunCount
maxValue: OverrunCountValue
43 changes: 22 additions & 21 deletions src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tests:
command: "readAttribute"
attribute: "MinSetpointDeadBand"
response:
saveAs: MinSetpointDeadBand
saveAs: MinSetpointDeadBandValue

- label:
"Saving value for comparision in step 6 read AbsMaxCoolSetpointLimit
Expand All @@ -65,7 +65,7 @@ tests:
command: "readAttribute"
attribute: "MinCoolSetpointLimit"
response:
saveAs: MinCoolSetpointLimit
saveAs: MinCoolSetpointLimitValue

- label:
"Saving value for comparision in step 17 read MaxCoolSetpointLimit
Expand All @@ -74,14 +74,14 @@ tests:
command: "readAttribute"
attribute: "MaxCoolSetpointLimit"
response:
saveAs: MaxCoolSetpointLimit
saveAs: MaxCoolSetpointLimitValue

- label: "Saving value for comparision in step 17 read MaxHeatSetpointLimit"
PICS: TSTAT.S.A0016
command: "readAttribute"
attribute: "MaxHeatSetpointLimit"
response:
saveAs: MaxHeatSetpointLimit
saveAs: MaxHeatSetpointLimitValue

- label:
"Saving value for comparision in step 13 read attribute
Expand All @@ -90,7 +90,7 @@ tests:
command: "readAttribute"
attribute: "OccupiedCoolingSetpoint"
response:
saveAs: OccupiedCoolingSetpoint
saveAs: OccupiedCoolingSetpointValue

- label:
"Saving value for comparision in step 15 read attribute
Expand All @@ -99,7 +99,7 @@ tests:
command: "readAttribute"
attribute: "AbsMinHeatSetpointLimit"
response:
saveAs: AbsMinHeat
saveAs: AbsMinHeatValue

- label:
"Saving value for comparision in step 15 read attribute
Expand All @@ -108,7 +108,7 @@ tests:
command: "readAttribute"
attribute: "AbsMaxHeatSetpointLimit"
response:
saveAs: AbsMaxHeat
saveAs: AbsMaxHeatValue

- label:
"Saving value for comparision in step 16 read
Expand All @@ -117,7 +117,7 @@ tests:
command: "readAttribute"
attribute: "UnoccupiedCoolingSetpoint"
response:
saveAs: UnoccupiedCoolingSetpoint
saveAs: UnoccupiedCoolingSetpointValue

- label: "Reads mandatory attributes from DUT: LocalTemperature"
command: "readAttribute"
Expand Down Expand Up @@ -157,7 +157,7 @@ tests:
response:
constraints:
type: int16s
maxValue: AbsMinCoolSetpointLimitStep5 - MinSetpointDeadBand
maxValue: AbsMinCoolSetpointLimitStep5 - MinSetpointDeadBandValue

- label:
"Read attribute AbsMinHeatSetpointLimit if TSTAT.S.F05 feature is
Expand Down Expand Up @@ -257,8 +257,8 @@ tests:
response:
constraints:
type: int16s
minValue: MinCoolSetpointLimit
maxValue: MaxCoolSetpointLimit
minValue: MinCoolSetpointLimitValue
maxValue: MaxCoolSetpointLimitValue

- label: "Read attribute OccupiedCoolingSetpoint from the DUT"
PICS: TSTAT.S.F01 && !TSTAT.S.A0017 && !TSTAT.S.A0018
Expand All @@ -280,7 +280,7 @@ tests:
constraints:
type: int16s
minValue: AbsMinCoolSetpointLimitStep5
maxValue: OccupiedCoolingSetpoint - MinSetpointDeadBand
maxValue: OccupiedCoolingSetpointValue - MinSetpointDeadBandValue

- label: "Read attribute OccupiedHeatingSetpoint from the DUT"
PICS: TSTAT.S.F00 && !TSTAT.S.F05
Expand All @@ -299,8 +299,8 @@ tests:
response:
constraints:
type: int16s
minValue: AbsMinHeat
maxValue: AbsMaxHeat
minValue: AbsMinHeatValue
maxValue: AbsMaxHeatValue

- label: "Read UnoccupiedCoolingSetpoint attribute from the DUT"
PICS: TSTAT.S.F01 && TSTAT.S.F02 && !TSTAT.S.F05
Expand All @@ -320,7 +320,8 @@ tests:
constraints:
type: int16s
minValue: 700
maxValue: UnoccupiedCoolingSetpoint - MinSetpointDeadBand
maxValue:
UnoccupiedCoolingSetpointValue - MinSetpointDeadBandValue

- label: "Read UnoccupiedHeatingSetpoint attribute from the DUT"
PICS: TSTAT.S.F00 && TSTAT.S.F02 && !TSTAT.S.F05
Expand All @@ -340,7 +341,7 @@ tests:
constraints:
type: int16s
minValue: 700
maxValue: MinCoolSetpointLimit - MinSetpointDeadBand
maxValue: MinCoolSetpointLimitValue - MinSetpointDeadBandValue

- label:
"Reads MinHeatSetpointLimit attribute from Server DUT and verifies
Expand All @@ -351,8 +352,8 @@ tests:
response:
constraints:
type: int16s
minValue: AbsMinHeat
maxValue: MaxHeatSetpointLimit
minValue: AbsMinHeatValue
maxValue: MaxHeatSetpointLimitValue

#Using hard coded values when optional attributes are not available
- label:
Expand Down Expand Up @@ -385,7 +386,7 @@ tests:
constraints:
type: int16s
minValue: 700
maxValue: MaxCoolSetpointLimit - MinSetpointDeadBand
maxValue: MaxCoolSetpointLimitValue - MinSetpointDeadBandValue

- label: "Read attribute MinCoolSetpointLimit from DUT"
PICS: TSTAT.S.A0017 && TSTAT.S.A0018 && TSTAT.S.A0005
Expand All @@ -395,7 +396,7 @@ tests:
constraints:
type: int16s
minValue: AbsMinCoolSetpointLimitStep5
maxValue: MaxCoolSetpointLimit
maxValue: MaxCoolSetpointLimitValue

- label: "Read attribute MinCoolSetpointLimit from DUT"
PICS: TSTAT.S.A0017 && !TSTAT.S.A0018 && !TSTAT.S.A0005
Expand All @@ -414,7 +415,7 @@ tests:
response:
constraints:
type: int16s
minValue: MinCoolSetpointLimit
minValue: MinCoolSetpointLimitValue
maxValue: AbsMaxCoolSetpointLimitStep6

- label: "Read attribute MinSetpointDeadBand from DUT"
Expand Down
Loading

0 comments on commit 341e169

Please sign in to comment.