Skip to content

Commit

Permalink
[MatterYamlTests] null values that are saved are not substituted when… (
Browse files Browse the repository at this point in the history
#29107)

* [MatterYamlTests] null values that are saved with saveAs are not substituted when the key used to saved them is used

* Update darwin-framework-tool tests codegen

* Add a new check in yaml_loader.py to ensure than the saveAs key is not the same as the attribute since this is a common mistake and it confuses the test suite that does not know if the attribute name should be replaced or not

* Update various YAML files such that they do not save the result of a read attribute with the exact same name than the attribute itself
  • Loading branch information
vivien-apple authored and pull[bot] committed Jan 8, 2024
1 parent 629254d commit c9b6701
Show file tree
Hide file tree
Showing 32 changed files with 850 additions and 620 deletions.
12 changes: 12 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,15 @@ def __init__(self, content):
self.tag_key_with_error(content, 'command')
arguments = content.get('arguments')
self.tag_key_with_error(arguments, 'value')


class TestStepSaveAsNameError(TestStepError):
"""Raise when a test step response save an attribute response with the same name than the attribute itself"""

def __init__(self, content):
message = 'The "saveAs" key can not be the same than the "attribute" key'
super().__init__(message)

self.tag_key_with_error(content, 'attribute')
response = content.get('response')
self.tag_key_with_error(response, 'saveAs')
5 changes: 2 additions & 3 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,8 @@ def _config_variable_substitution(self, value):
variable_info = self._runtime_config_variable_storage[token]
if type(variable_info) is dict and 'defaultValue' in variable_info:
variable_info = variable_info['defaultValue']
if variable_info is not None:
tokens[idx] = variable_info
substitution_occured = True
tokens[idx] = variable_info
substitution_occured = True

if len(tokens) == 1:
return tokens[0]
Expand Down
12 changes: 11 additions & 1 deletion scripts/py_matter_yamltests/matter_yamltests/yaml_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

from .errors import (TestStepArgumentsValueError, TestStepError, TestStepGroupEndPointError, TestStepGroupResponseError,
TestStepInvalidTypeError, TestStepKeyError, TestStepNodeIdAndGroupIdError, TestStepResponseVariableError,
TestStepValueAndValuesError, TestStepVerificationStandaloneError, TestStepWaitResponseError)
TestStepSaveAsNameError, TestStepValueAndValuesError, TestStepVerificationStandaloneError,
TestStepWaitResponseError)
from .fixes import add_yaml_support_for_scientific_notation_without_dot

try:
Expand Down Expand Up @@ -123,6 +124,7 @@ def __check_test_step(self, config: dict, content):
self.__rule_wait_should_not_expect_a_response(content)
self.__rule_response_variable_should_exist_in_config(config, content)
self.__rule_argument_value_is_only_when_writing_attributes(content)
self.__rule_saveas_name_and_attribute_name_should_be_different(content)

if 'arguments' in content:
arguments = content.get('arguments')
Expand Down Expand Up @@ -272,3 +274,11 @@ def __rule_argument_value_is_only_when_writing_attributes(self, content):
arguments = content.get('arguments')
if 'value' in arguments and operation != 'writeAttribute':
raise TestStepArgumentsValueError(content)

def __rule_saveas_name_and_attribute_name_should_be_different(self, content):
if content.get('command') == 'readAttribute' and 'response' in content:
attribute_name = content.get('attribute')
response = content.get('response')
if 'saveAs' in response:
if response.get('saveAs') == attribute_name:
raise TestStepSaveAsNameError(content)
62 changes: 31 additions & 31 deletions src/app/tests/suites/DL_Schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tests:
command: "readAttribute"
attribute: "NumberOfTotalUsersSupported"
response:
saveAs: NumberOfTotalUsersSupported
saveAs: NumberOfTotalUsersSupportedValue
value: 10

- label:
Expand All @@ -67,7 +67,7 @@ tests:
command: "readAttribute"
attribute: "NumberOfWeekDaySchedulesSupportedPerUser"
response:
saveAs: NumberOfWeekDaySchedulesSupportedPerUser
saveAs: NumberOfWeekDaySchedulesSupportedPerUserValue
value: 10

- label:
Expand All @@ -76,14 +76,14 @@ tests:
command: "readAttribute"
attribute: "NumberOfYearDaySchedulesSupportedPerUser"
response:
saveAs: NumberOfYearDaySchedulesSupportedPerUser
saveAs: NumberOfYearDaySchedulesSupportedPerUserValue
value: 10

- label: "Get Max number of Holiday schedules and verify default value"
command: "readAttribute"
attribute: "NumberOfHolidaySchedulesSupported"
response:
saveAs: NumberOfHolidaySchedulesSupported
saveAs: NumberOfHolidaySchedulesSupportedValue
value: 10

#
Expand Down Expand Up @@ -115,7 +115,7 @@ tests:
arguments:
values:
- name: "WeekDayIndex"
value: NumberOfWeekDaySchedulesSupportedPerUser + 1
value: NumberOfWeekDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
- name: "DaysMask"
Expand Down Expand Up @@ -159,7 +159,7 @@ tests:
- name: "WeekDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
- name: "DaysMask"
value: 0x01
- name: "StartHour"
Expand Down Expand Up @@ -427,13 +427,13 @@ tests:
arguments:
values:
- name: "WeekDayIndex"
value: NumberOfWeekDaySchedulesSupportedPerUser + 1
value: NumberOfWeekDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
response:
values:
- name: "WeekDayIndex"
value: NumberOfWeekDaySchedulesSupportedPerUser + 1
value: NumberOfWeekDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
- name: "Status"
Expand Down Expand Up @@ -463,13 +463,13 @@ tests:
- name: "WeekDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
response:
values:
- name: "WeekDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
- name: "Status"
value: 0x85

Expand Down Expand Up @@ -513,7 +513,7 @@ tests:
arguments:
values:
- name: "YearDayIndex"
value: NumberOfYearDaySchedulesSupportedPerUser + 1
value: NumberOfYearDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
- name: "LocalStartTime"
Expand Down Expand Up @@ -545,7 +545,7 @@ tests:
- name: "YearDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
- name: "LocalStartTime"
value: 12345
- name: "LocalEndTime"
Expand Down Expand Up @@ -625,13 +625,13 @@ tests:
arguments:
values:
- name: "YearDayIndex"
value: NumberOfYearDaySchedulesSupportedPerUser + 1
value: NumberOfYearDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
response:
values:
- name: "YearDayIndex"
value: NumberOfYearDaySchedulesSupportedPerUser + 1
value: NumberOfYearDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
- name: "Status"
Expand Down Expand Up @@ -661,13 +661,13 @@ tests:
- name: "YearDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
response:
values:
- name: "YearDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
- name: "Status"
value: 0x85

Expand Down Expand Up @@ -711,7 +711,7 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported + 1
value: NumberOfHolidaySchedulesSupportedValue + 1
- name: "LocalStartTime"
value: 12345
- name: "LocalEndTime"
Expand Down Expand Up @@ -785,11 +785,11 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported + 1
value: NumberOfHolidaySchedulesSupportedValue + 1
response:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported + 1
value: NumberOfHolidaySchedulesSupportedValue + 1
- name: "Status"
value: 0x85

Expand Down Expand Up @@ -925,7 +925,7 @@ tests:
arguments:
values:
- name: "WeekDayIndex"
value: NumberOfWeekDaySchedulesSupportedPerUser + 1
value: NumberOfWeekDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
response:
Expand All @@ -949,7 +949,7 @@ tests:
- name: "WeekDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
response:
error: INVALID_COMMAND

Expand Down Expand Up @@ -1050,7 +1050,7 @@ tests:
arguments:
values:
- name: "YearDayIndex"
value: NumberOfYearDaySchedulesSupportedPerUser + 1
value: NumberOfYearDaySchedulesSupportedPerUserValue + 1
- name: "UserIndex"
value: 1
response:
Expand All @@ -1074,7 +1074,7 @@ tests:
- name: "YearDayIndex"
value: 1
- name: "UserIndex"
value: NumberOfTotalUsersSupported + 1
value: NumberOfTotalUsersSupportedValue + 1
response:
error: INVALID_COMMAND

Expand Down Expand Up @@ -1171,7 +1171,7 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfYearDaySchedulesSupportedPerUser + 1
value: NumberOfYearDaySchedulesSupportedPerUserValue + 1
response:
error: INVALID_COMMAND

Expand Down Expand Up @@ -1896,7 +1896,7 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
- name: "LocalStartTime"
value: 1
- name: "LocalEndTime"
Expand All @@ -1909,11 +1909,11 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
response:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
- name: "Status"
value: 0x0
- name: "LocalStartTime"
Expand Down Expand Up @@ -2027,11 +2027,11 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
response:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
- name: "Status"
value: 0x0
- name: "LocalStartTime"
Expand Down Expand Up @@ -2129,11 +2129,11 @@ tests:
arguments:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
response:
values:
- name: "HolidayIndex"
value: NumberOfHolidaySchedulesSupported
value: NumberOfHolidaySchedulesSupportedValue
- name: "Status"
value: 0x8B

Expand Down
Loading

0 comments on commit c9b6701

Please sign in to comment.