Skip to content

Commit bcfd0d1

Browse files
committed
fix(tests): assert global to_dict rather than model-level one
1 parent 056a251 commit bcfd0d1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

templates/python/tests/e2e/e2e.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Test{{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}{{#isSyncClien
4040
{{#body}}
4141
resp = {{^isSyncClient}}await {{/isSyncClient}}{{#lambda.pascalcase}}{{{client}}}{{#isSyncClient}}Sync{{/isSyncClient}}{{/lambda.pascalcase}}(self._e2e_app_id, self._e2e_api_key{{#hasRegionalHost}}, "{{{defaultRegion}}}"{{/hasRegionalHost}}).{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}} request_options={ {{#requestOptions.headers.parameters}}"headers":loads("""{{{.}}}"""),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}"query_parameters":loads("""{{{.}}}"""),{{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
4242
_expected_body = loads("""{{{.}}}""")
43-
assert self._helpers.union(_expected_body, resp) == _expected_body
43+
assert self._helpers.union(_expected_body, self._helpers.unwrap(resp)) == _expected_body
4444
{{/body}}
4545
{{/response}}
4646

tests/output/python/tests/helpers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
class Helpers:
2+
def unwrap(self, resp):
3+
""" converts the object response to its dictionary form, if it's a list, every items are iterated on and we call to_dict on it, otherwise we just call to_dict """
4+
if isinstance(resp, list):
5+
_res = []
6+
for _, r in enumerate(resp):
7+
_res.append(r.to_dict())
8+
return _res
9+
return resp.to_dict()
10+
211
def union(self, expected, received):
312
"""
413
creates a new result based on the keys of 'expected' that are also in 'received'
@@ -9,8 +18,6 @@ def union(self, expected, received):
918
_res.append(self.union(_v, received[_iv]))
1019
return _res
1120
if isinstance(expected, dict):
12-
if hasattr(received, "to_dict"):
13-
received = received.to_dict()
1421
_res = {}
1522
for k, v in expected.items():
1623
if k not in received or received[k] is None:

0 commit comments

Comments
 (0)