Skip to content

Commit 2bec98a

Browse files
api-clients-generation-pipeline[bot]nmueschci.datadog-api-spec
authored
Add scenario for each error response code that isn't 401 or 403 (#225)
* Add exception scenarios * Only create stub response if exception is subclass of ApiException * Remove issubclass * Regenerate client from commit 426d7a0 of spec repo Co-authored-by: Nicholas Muesch <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent b503db3 commit 2bec98a

39 files changed

+2232
-14
lines changed

.apigentools-info

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.4.1.dev2",
7-
"regenerated": "2021-01-13 11:20:30.289161",
8-
"spec_repo_commit": "166fecc"
7+
"regenerated": "2021-01-13 15:26:23.348231",
8+
"spec_repo_commit": "426d7a0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev2",
12-
"regenerated": "2021-01-13 11:20:41.152849",
13-
"spec_repo_commit": "166fecc"
12+
"regenerated": "2021-01-13 15:26:33.836090",
13+
"spec_repo_commit": "426d7a0"
1414
}
1515
}
1616
}

tests/conftest.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def api(context, package_name, client, name):
276276
package = importlib.import_module(f"{package_name}.api.{module_name}_api")
277277
context["api"] = {
278278
"api": getattr(package, name + "Api")(client),
279+
"package": package_name,
279280
"calls": [],
280281
}
281282

@@ -425,10 +426,18 @@ def cleanup(api, operation_id, response, client=client):
425426
def execute_request(undo, context, client):
426427
"""Execute the prepared request."""
427428
api_request = context["api_request"]
428-
api_request["response"] = api_request["request"].call_with_http_info(
429-
*api_request["args"], **api_request["kwargs"]
430-
)
431-
client.last_response.urllib3_response.close()
429+
exceptions = importlib.import_module(context["api"]["package"] + ".exceptions")
430+
431+
try:
432+
api_request["response"] = api_request["request"].call_with_http_info(
433+
*api_request["args"], **api_request["kwargs"]
434+
)
435+
client.last_response.urllib3_response.close()
436+
except exceptions.ApiException as e:
437+
# If we have an exception, make a stub response object to use for assertions
438+
# Instead of finding the response class of the method, we use the fact that all
439+
# responses returned have an ordered response of body|status|headers
440+
api_request["response"] = [e.body, e.status, e.headers]
432441

433442
api = api_request["api"]
434443
operation_id = api_request["request"].settings["operation_id"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2021-01-11T12:02:02.232318-05:00
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Content-Type:
8+
- application/json
9+
Dd-Operation-Id:
10+
- GetMonitor
11+
User-Agent:
12+
- datadog-api-client-python/1.0.0b5.dev24+dirty (python 3.7.9; os Darwin; arch
13+
x86_64)
14+
method: GET
15+
uri: https://api.datadoghq.com/api/v1/monitor/12345
16+
response:
17+
body:
18+
string: '{"errors":["Monitor not found"]}'
19+
headers:
20+
Connection:
21+
- keep-alive
22+
Content-Length:
23+
- '32'
24+
Content-Type:
25+
- application/json
26+
Date:
27+
- Mon, 11 Jan 2021 17:06:26 GMT
28+
cache-control:
29+
- no-cache
30+
content-security-policy:
31+
- frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report
32+
pragma:
33+
- no-cache
34+
strict-transport-security:
35+
- max-age=15724800;
36+
vary:
37+
- Accept-Encoding
38+
x-content-type-options:
39+
- nosniff
40+
x-dd-version:
41+
- '35.3679038'
42+
x-frame-options:
43+
- SAMEORIGIN
44+
x-ratelimit-limit:
45+
- '3000'
46+
x-ratelimit-period:
47+
- '10'
48+
x-ratelimit-remaining:
49+
- '2999'
50+
x-ratelimit-reset:
51+
- '4'
52+
status:
53+
code: 404
54+
message: Not Found
55+
version: 1

tests/v1/features/aws_integration.feature

+75
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,78 @@ Feature: AWS Integration
6868
And body {}
6969
When the request is sent
7070
Then the response status is 200 OK
71+
72+
@generated @skip
73+
Scenario: Delete an AWS integration returns "Bad Request" response
74+
Given new "DeleteAWSAccount" request
75+
And body {}
76+
When the request is sent
77+
Then the response status is 400 Bad Request
78+
79+
@generated @skip
80+
Scenario: Delete an AWS integration returns "Conflict Error" response
81+
Given new "DeleteAWSAccount" request
82+
And body {}
83+
When the request is sent
84+
Then the response status is 409 Conflict Error
85+
86+
@generated @skip
87+
Scenario: List all AWS integrations returns "Bad Request" response
88+
Given new "ListAWSAccounts" request
89+
When the request is sent
90+
Then the response status is 400 Bad Request
91+
92+
@generated @skip
93+
Scenario: Create an AWS integration returns "Bad Request" response
94+
Given new "CreateAWSAccount" request
95+
And body {}
96+
When the request is sent
97+
Then the response status is 400 Bad Request
98+
99+
@generated @skip
100+
Scenario: Create an AWS integration returns "Conflict Error" response
101+
Given new "CreateAWSAccount" request
102+
And body {}
103+
When the request is sent
104+
Then the response status is 409 Conflict Error
105+
106+
@generated @skip
107+
Scenario: Update an AWS integration returns "Bad Request" response
108+
Given new "UpdateAWSAccount" request
109+
And body {}
110+
When the request is sent
111+
Then the response status is 400 Bad Request
112+
113+
@generated @skip
114+
Scenario: Update an AWS integration returns "Conflict Error" response
115+
Given new "UpdateAWSAccount" request
116+
And body {}
117+
When the request is sent
118+
Then the response status is 409 Conflict Error
119+
120+
@generated @skip
121+
Scenario: Delete a tag filtering entry returns "Bad Request" response
122+
Given new "DeleteAWSTagFilter" request
123+
And body {}
124+
When the request is sent
125+
Then the response status is 400 Bad Request
126+
127+
@generated @skip
128+
Scenario: Get all AWS tag filters returns "Bad Request" response
129+
Given new "ListAWSTagFilters" request
130+
When the request is sent
131+
Then the response status is 400 Bad Request
132+
133+
@generated @skip
134+
Scenario: Set an AWS tag filter returns "Bad Request" response
135+
Given new "CreateAWSTagFilter" request
136+
And body {}
137+
When the request is sent
138+
Then the response status is 400 Bad Request
139+
140+
@generated @skip
141+
Scenario: Generate a new external ID returns "Bad Request" response
142+
Given new "CreateNewAWSExternalID" request
143+
And body {}
144+
When the request is sent
145+
Then the response status is 400 Bad Request

tests/v1/features/aws_logs_integration.feature

+41
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,44 @@ Feature: AWS Logs Integration
5555
And body {}
5656
When the request is sent
5757
Then the response status is 200 OK
58+
59+
@generated @skip
60+
Scenario: Delete an AWS Logs integration returns "Bad Request" response
61+
Given new "DeleteAWSLambdaARN" request
62+
And body {}
63+
When the request is sent
64+
Then the response status is 400 Bad Request
65+
66+
@generated @skip
67+
Scenario: List all AWS Logs integrations returns "Bad Request" response
68+
Given new "ListAWSLogsIntegrations" request
69+
When the request is sent
70+
Then the response status is 400 Bad Request
71+
72+
@generated @skip
73+
Scenario: Add AWS Log Lambda ARN returns "Bad Request" response
74+
Given new "CreateAWSLambdaARN" request
75+
And body {}
76+
When the request is sent
77+
Then the response status is 400 Bad Request
78+
79+
@generated @skip
80+
Scenario: Check that an AWS Lambda Function exists returns "Bad Request" response
81+
Given new "CheckAWSLogsLambdaAsync" request
82+
And body {}
83+
When the request is sent
84+
Then the response status is 400 Bad Request
85+
86+
@generated @skip
87+
Scenario: Enable an AWS Logs integration returns "Bad Request" response
88+
Given new "EnableAWSLogServices" request
89+
And body {}
90+
When the request is sent
91+
Then the response status is 400 Bad Request
92+
93+
@generated @skip
94+
Scenario: Check permissions for log services returns "Bad Request" response
95+
Given new "CheckAWSLogsServicesAsync" request
96+
And body {}
97+
When the request is sent
98+
Then the response status is 400 Bad Request

tests/v1/features/azure_integration.feature

+34
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,37 @@ Feature: Azure Integration
4242
And body {}
4343
When the request is sent
4444
Then the response status is 200 OK
45+
46+
@generated @skip
47+
Scenario: Delete an Azure integration returns "Bad Request" response
48+
Given new "DeleteAzureIntegration" request
49+
And body {}
50+
When the request is sent
51+
Then the response status is 400 Bad Request
52+
53+
@generated @skip
54+
Scenario: List all Azure integrations returns "Bad Request" response
55+
Given new "ListAzureIntegration" request
56+
When the request is sent
57+
Then the response status is 400 Bad Request
58+
59+
@generated @skip
60+
Scenario: Create an Azure integration returns "Bad Request" response
61+
Given new "CreateAzureIntegration" request
62+
And body {}
63+
When the request is sent
64+
Then the response status is 400 Bad Request
65+
66+
@generated @skip
67+
Scenario: Update an Azure integration returns "Bad Request" response
68+
Given new "UpdateAzureIntegration" request
69+
And body {}
70+
When the request is sent
71+
Then the response status is 400 Bad Request
72+
73+
@generated @skip
74+
Scenario: Update Azure integration host filters returns "Bad Request" response
75+
Given new "UpdateAzureHostFilters" request
76+
And body {}
77+
When the request is sent
78+
Then the response status is 400 Bad Request

tests/v1/features/dashboard_lists.feature

+37
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,40 @@ Feature: Dashboard Lists
4242
And body {}
4343
When the request is sent
4444
Then the response status is 200 OK
45+
46+
@generated @skip
47+
Scenario: Create a dashboard list returns "Bad Request" response
48+
Given new "CreateDashboardList" request
49+
And body {}
50+
When the request is sent
51+
Then the response status is 400 Bad Request
52+
53+
@generated @skip
54+
Scenario: Delete a dashboard list returns "Not Found" response
55+
Given new "DeleteDashboardList" request
56+
And request contains "list_id" parameter from "<PATH>"
57+
When the request is sent
58+
Then the response status is 404 Not Found
59+
60+
@generated @skip
61+
Scenario: Get a dashboard list returns "Not Found" response
62+
Given new "GetDashboardList" request
63+
And request contains "list_id" parameter from "<PATH>"
64+
When the request is sent
65+
Then the response status is 404 Not Found
66+
67+
@generated @skip
68+
Scenario: Update a dashboard list returns "Bad Request" response
69+
Given new "UpdateDashboardList" request
70+
And request contains "list_id" parameter from "<PATH>"
71+
And body {}
72+
When the request is sent
73+
Then the response status is 400 Bad Request
74+
75+
@generated @skip
76+
Scenario: Update a dashboard list returns "Not Found" response
77+
Given new "UpdateDashboardList" request
78+
And request contains "list_id" parameter from "<PATH>"
79+
And body {}
80+
When the request is sent
81+
Then the response status is 404 Not Found

tests/v1/features/dashboards.feature

+37
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,40 @@ Feature: Dashboards
4343
And body {}
4444
When the request is sent
4545
Then the response status is 200 OK
46+
47+
@generated @skip
48+
Scenario: Create a new dashboard returns "Bad Request" response
49+
Given new "CreateDashboard" request
50+
And body {}
51+
When the request is sent
52+
Then the response status is 400 Bad Request
53+
54+
@generated @skip
55+
Scenario: Delete a dashboard returns "Dashboards Not Found" response
56+
Given new "DeleteDashboard" request
57+
And request contains "dashboard_id" parameter from "<PATH>"
58+
When the request is sent
59+
Then the response status is 404 Dashboards Not Found
60+
61+
@generated @skip
62+
Scenario: Get a dashboard returns "Item Not Found" response
63+
Given new "GetDashboard" request
64+
And request contains "dashboard_id" parameter from "<PATH>"
65+
When the request is sent
66+
Then the response status is 404 Item Not Found
67+
68+
@generated @skip
69+
Scenario: Update a dashboard returns "Bad Request" response
70+
Given new "UpdateDashboard" request
71+
And request contains "dashboard_id" parameter from "<PATH>"
72+
And body {}
73+
When the request is sent
74+
Then the response status is 400 Bad Request
75+
76+
@generated @skip
77+
Scenario: Update a dashboard returns "Item Not Found" response
78+
Given new "UpdateDashboard" request
79+
And request contains "dashboard_id" parameter from "<PATH>"
80+
And body {}
81+
When the request is sent
82+
Then the response status is 404 Item Not Found

0 commit comments

Comments
 (0)