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] Update values from config variables at beginning t… #24570

Merged
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
4 changes: 4 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def convert_yaml_octet_string_to_bytes(s: str) -> bytes:
This handles any c-style hex escapes (e.g. \x5a) and hex: prefix
'''
# Step 0: Check if this is already of type bytes
if isinstance(s, bytes):
return s

# Step 1: handle explicit "hex:" prefix
if s.startswith('hex:'):
return binascii.unhexlify(s[4:])
Expand Down
20 changes: 15 additions & 5 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ def __init__(self, test: dict, config: dict, definitions):
response_mapping = self._as_mapping(
definitions, self.cluster, command.output_param)

self._update_with_definition(
self.arguments_with_placeholders, argument_mapping)
self._update_with_definition(
self.response_with_placeholders, response_mapping)
self.argument_mapping = argument_mapping
self.response_mapping = response_mapping
self.update_arguments(self.arguments_with_placeholders)
self.update_response(self.response_with_placeholders)

# This performs a very basic sanity parse time check of constrains. This parsing happens
# This performs a very basic sanity parse time check of constraints. This parsing happens
# again inside post processing response since at that time we will have required variables
# to substitute in. This parsing check here has value since some test can take a really
# long time to run so knowing earlier on that the test step would have failed at parsing
Expand Down Expand Up @@ -296,6 +296,14 @@ def _as_mapping(self, definitions, cluster_name, target_name):

return target_name

def update_arguments(self, arguments_with_placeholders):
self._update_with_definition(
arguments_with_placeholders, self.argument_mapping)

def update_response(self, response_with_placeholders):
self._update_with_definition(
response_with_placeholders, self.response_mapping)

def _update_with_definition(self, container: dict, mapping_type):
if not container or not mapping_type:
return
Expand Down Expand Up @@ -384,6 +392,8 @@ def __init__(self, test: _TestStepWithPlaceholders, runtime_config_variable_stor
self.response = copy.deepcopy(test.response_with_placeholders)
self._update_placeholder_values(self.arguments)
self._update_placeholder_values(self.response)
test.update_arguments(self.arguments)
test.update_response(self.response)

@property
def is_enabled(self):
Expand Down