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

[matter_yamltests] Validate only the expected values for list/dict wh… #24475

Merged
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
30 changes: 24 additions & 6 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,32 @@ def _response_values_validation(self, response, result):
received_value = received_value.get(
expected_name) if received_value else None

# TODO Supports Array/List. See an exemple of failure in TestArmFailSafe.yaml
expected_value = value.get('value')
if expected_value == received_value:
result.success(
check_type, error_success.format(name=expected_name, value=received_value))
if self._response_value_validation(expected_value, received_value):
result.success(check_type, error_success.format(
name=expected_name, value=expected_value))
else:
result.error(
check_type, error_failure.format(name=expected_name, value=expected_value))
result.error(check_type, error_failure.format(
name=expected_name, value=expected_value))

def _response_value_validation(self, expected_value, received_value):
if isinstance(expected_value, list):
if len(expected_value) != len(received_value):
return False

for index, expected_item in enumerate(expected_value):
received_item = received_value[index]
if not self._response_value_validation(expected_item, received_item):
return False
return True
elif isinstance(expected_value, dict):
for key, expected_item in expected_value.items():
received_item = received_value.get(key)
if not self._response_value_validation(expected_item, received_item):
return False
return True
else:
return expected_value == received_value

def _response_constraints_validation(self, response, result):
check_type = PostProcessCheckType.CONSTRAINT_VALIDATION
Expand Down