Skip to content

Commit b47d86d

Browse files
authored
support regex comparison for transformed values (#718)
1 parent ad084f8 commit b47d86d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/rpdk/core/contract/resource_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,17 @@ def convert_type(document_input, transformed_property):
268268
def compare(document_input, document_output):
269269
try:
270270
if isinstance(document_input, str):
271-
return re.match(f"^{document_input}$", document_output)
271+
return bool(re.match(f"^{document_input}$", document_output))
272272
return document_input == document_output
273273
except re.error:
274274
return document_input == document_output
275275

276276
def transform(self, property_transform_value, input_model):
277-
LOG.warning("This is the transform %s", property_transform_value)
277+
LOG.debug("This is the transform %s", property_transform_value)
278278
content = self.transformation_template.render(
279279
input_model=input_model, jsonata_expression=property_transform_value
280280
)
281-
LOG.warning("This is the content %s", content)
281+
LOG.debug("This is the content %s", content)
282282
file = tempfile.NamedTemporaryFile(
283283
mode="w+b",
284284
buffering=-1,

src/rpdk/core/contract/suite/handler_commons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def test_input_equals_output(resource_client, input_model, output_model):
180180
pruned_input_model[key], pruned_output_model[key]
181181
)
182182
else:
183-
assert (
184-
pruned_input_model[key] == pruned_output_model[key]
183+
assert resource_client.compare(
184+
pruned_input_model[key], pruned_output_model[key]
185185
), assertion_error_message
186186
except KeyError as e:
187187
raise AssertionError(assertion_error_message) from e

0 commit comments

Comments
 (0)