Skip to content

Commit 88dc3cc

Browse files
therveci.datadog-api-spec
andauthored
Change synthetics unparsed test (#1255)
* CHange synthetics unparsed test In preparation for a method enum change, let's change the test. This also fixes a small unparsed condition. * pre-commit fixes Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 75856d9 commit 88dc3cc

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.generator/src/generator/templates/model_utils.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ class ModelComposed(OpenApiModel):
471471
self._composed_instances = composed_info[0]
472472
self._var_name_to_model_instances = composed_info[1]
473473
self._additional_properties_model_instances = composed_info[2]
474+
self._unparsed = any(isinstance(composed_instance, UnparsedObject)
475+
for composed_instance in self._composed_instances)
474476

475477
def __setitem__(self, name, value):
476478
"""Set the value of an attribute using square-bracket notation: `instance[attr] = val`."""

src/datadog_api_client/model_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ def __init__(self, kwargs):
473473
self._composed_instances = composed_info[0]
474474
self._var_name_to_model_instances = composed_info[1]
475475
self._additional_properties_model_instances = composed_info[2]
476+
self._unparsed = any(
477+
isinstance(composed_instance, UnparsedObject) for composed_instance in self._composed_instances
478+
)
476479

477480
def __setitem__(self, name, value):
478481
"""Set the value of an attribute using square-bracket notation: `instance[attr] = val`."""

tests/test_deserialization.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
77
from datadog_api_client.v1.model.synthetics_browser_test import SyntheticsBrowserTest
8-
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest
8+
from datadog_api_client.v1.model.synthetics_assertion import SyntheticsAssertion
99
from datadog_api_client.v2.model.logs_aggregate_response import LogsAggregateResponse
1010
from datadog_api_client.v2.model.logs_archive import LogsArchive
1111
from datadog_api_client.v2.model.logs_archive_destination import LogsArchiveDestination
@@ -216,12 +216,12 @@ def test_unknown_nested_enum():
216216
"config": {
217217
"request": {
218218
"url": "https://www.10.0.0.1.xip.io",
219-
"method": "A non existent method",
219+
"method": "GET",
220220
"timeout": 30
221221
},
222222
"assertions": [
223223
{
224-
"operator": "is",
224+
"operator": "not-an-operator",
225225
"type": "statusCode",
226226
"target": 200
227227
}
@@ -236,9 +236,9 @@ def test_unknown_nested_enum():
236236
json.loads(body), (SyntheticsAPITest,), ["received_data"], True, True, config
237237
)
238238
assert isinstance(deserialized_data, SyntheticsAPITest)
239-
assert isinstance(deserialized_data.config.request, SyntheticsTestRequest)
240-
assert str(deserialized_data.config.request.method) == "A non existent method"
241-
assert deserialized_data.config.request.method._unparsed
239+
assert isinstance(deserialized_data.config.assertions[0], SyntheticsAssertion)
240+
assert str(deserialized_data.config.assertions[0].operator) == "not-an-operator"
241+
assert deserialized_data.config.assertions[0]._unparsed
242242

243243

244244
def test_unknown_nested_one_of():

0 commit comments

Comments
 (0)