Skip to content

Commit 93b3a6f

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Add new has field assertion (#1582)
* add new assertion * fix example * fix example * Regenerate client from commit e70d9c5c of spec repo --------- Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 4e52c63 commit 93b3a6f

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.5",
7-
"regenerated": "2023-07-14 14:04:10.985041",
8-
"spec_repo_commit": "3868f953"
7+
"regenerated": "2023-07-17 14:34:00.158345",
8+
"spec_repo_commit": "e70d9c5c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-07-14 14:04:11.045806",
13-
"spec_repo_commit": "3868f953"
12+
"regenerated": "2023-07-17 14:34:00.171646",
13+
"spec_repo_commit": "e70d9c5c"
1414
}
1515
}
1616
}

.generator/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,16 @@ def expect_false(context, response_path):
534534
"""Check that a response attribute is false."""
535535

536536

537+
@then(parsers.parse('the response "{response_path}" has field "{field}"'))
538+
def expect_response_has_field(context, response_path, field):
539+
"""Check that a response has field."""
540+
541+
537542
@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
538543
def expect_array_contains_object(context, response_path, key_path, value):
539544
"""Check that a response attribute contains an object with the specified key and value."""
540545

546+
541547
@then(parsers.parse('the response "{response_path}" array contains value {value}'))
542548
def expect_array_contains_object(context, response_path, value):
543549
"""Check that a response array contains the specified value."""

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,13 @@ def expect_false(context, response_path):
668668
assert not response_value
669669

670670

671+
@then(parsers.parse('the response "{response_path}" has field "{field}"'))
672+
def expect_response_has_field(context, response_path, field):
673+
"""Check that a response path has field."""
674+
response_value = glom(context["api_request"]["response"][0], response_path)
675+
assert field in response_value
676+
677+
671678
@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
672679
def expect_array_contains_object(context, response_path, key_path, value):
673680
response_value = glom(context["api_request"]["response"][0], response_path)

tests/v2/features/teams.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Feature: Teams
5555
And body with value {"data": {"attributes": {"handle": "handle-{{ unique_hash }}", "name": "name-{{ unique_hash }}"}, "relationships": {"users": {"data": []}}, "type": "team"}}
5656
When the request is sent
5757
Then the response status is 201 CREATED
58+
And the response "data" has field "id"
5859

5960
@team:DataDog/core-app
6061
Scenario: Get a team link returns "API error response." response

0 commit comments

Comments
 (0)