Skip to content

Commit 9667def

Browse files
api-clients-generation-pipeline[bot]nkzouci.datadog-api-spec
authored
Add a unique_hash test fixture (#1456)
* add new unique_hash fixture using truncated sha256 * remove test prefix * Regenerate client from commit b590b791 of spec repo --------- Co-authored-by: Kevin Zou <[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 b06a19b commit 9667def

File tree

48 files changed

+148
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+148
-140
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.4",
7-
"regenerated": "2023-05-09 21:22:58.053236",
8-
"spec_repo_commit": "2ba8c6cd"
7+
"regenerated": "2023-05-11 13:17:34.302913",
8+
"spec_repo_commit": "b590b791"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-05-09 21:22:58.065936",
13-
"spec_repo_commit": "2ba8c6cd"
12+
"regenerated": "2023-05-11 13:17:34.315254",
13+
"spec_repo_commit": "b590b791"
1414
}
1515
}
1616
}

.generator/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from dateutil.relativedelta import relativedelta
1414
from jinja2 import Environment, FileSystemLoader, Template
1515
from pytest_bdd import given, parsers, then, when
16+
import hashlib
1617

1718
from generator import openapi
1819

@@ -252,6 +253,7 @@ def is_used(self, key):
252253
imports = defaultdict(set)
253254
given = defaultdict(dict)
254255

256+
unique_hash = hashlib.sha256(unique.encode("utf-8")).hexdigest()[:16]
255257
ctx = {
256258
"undo_operations": [],
257259
"unique": unique,
@@ -260,6 +262,7 @@ def is_used(self, key):
260262
"unique_alnum": PATTERN_ALPHANUM.sub("", unique),
261263
"unique_lower_alnum": PATTERN_ALPHANUM.sub("", unique).lower(),
262264
"unique_upper_alnum": PATTERN_ALPHANUM.sub("", unique).upper(),
265+
"unique_hash": unique_hash,
263266
"timestamp": relative_time(imports, replace_values, freezed_time, False),
264267
"timeISO": relative_time(imports, replace_values, freezed_time, True),
265268
"_replace_values": replace_values,

examples/v2/teams/CreateTeam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
body = TeamCreateRequest(
1515
data=TeamCreate(
1616
attributes=TeamCreateAttributes(
17-
handle="1636629071",
18-
name="1636629071",
17+
handle="handle-a0fc0297eb519635",
18+
name="name-a0fc0297eb519635",
1919
),
2020
relationships=TeamCreateRelationships(
2121
users=RelationshipToUsers(

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Define basic fixtures."""
33

44
import os
5+
import hashlib
56

67
RECORD = os.getenv("RECORD", "false").lower()
78
SLEEP_AFTER_REQUEST = int(os.getenv("SLEEP_AFTER_REQUEST", "0"))
@@ -206,6 +207,7 @@ def context(vcr, unique, freezed_time):
206207
Return a mapping with all defined fixtures, all objects created by `given` steps,
207208
and the undo operations to perform after a test scenario.
208209
"""
210+
unique_hash = hashlib.sha256(unique.encode("utf-8")).hexdigest()[:16]
209211
ctx = {
210212
"undo_operations": [],
211213
"unique": unique,
@@ -214,6 +216,7 @@ def context(vcr, unique, freezed_time):
214216
"unique_alnum": PATTERN_ALPHANUM.sub("", unique),
215217
"unique_lower_alnum": PATTERN_ALPHANUM.sub("", unique).lower(),
216218
"unique_upper_alnum": PATTERN_ALPHANUM.sub("", unique).upper(),
219+
"unique_hash": unique_hash,
217220
"timestamp": relative_time(freezed_time, False),
218221
"timeISO": relative_time(freezed_time, True),
219222
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-03-27T18:32:58.153Z
1+
2023-05-10T16:25:49.959Z

tests/v2/cassettes/test_scenarios/test_create_a_team_link_returns_api_error_response_response.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"data":{"attributes":{"handle":"1679941978","name":"1679941978"},"type":"team"}}'
3+
body: '{"data":{"attributes":{"handle":"handle-7f82f490dc758fbf","name":"name-7f82f490dc758fbf"},"type":"team"}}'
44
headers:
55
accept:
66
- application/json
@@ -10,7 +10,7 @@ interactions:
1010
uri: https://api.datadoghq.com/api/v2/team
1111
response:
1212
body:
13-
string: '{"data":{"type":"team","id":"cc3d71dc-cccd-11ed-ac3a-da7ad0900002","attributes":{"name":"1679941978","handle":"1679941978","summary":null,"description":null,"color":10,"created_at":"2023-03-27T18:32:58.528371+00:00","modified_at":"2023-03-27T18:32:58.528375+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/cc3d71dc-cccd-11ed-ac3a-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/cc3d71dc-cccd-11ed-ac3a-da7ad0900002/permission-settings"}}}}}
13+
string: '{"data":{"type":"team","id":"5391cf72-ef4f-11ed-9b09-da7ad0900002","attributes":{"name":"name-7f82f490dc758fbf","handle":"handle-7f82f490dc758fbf","summary":null,"description":null,"color":11,"created_at":"2023-05-10T16:25:50.187661+00:00","modified_at":"2023-05-10T16:25:50.187665+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/5391cf72-ef4f-11ed-9b09-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/5391cf72-ef4f-11ed-9b09-da7ad0900002/permission-settings"}}}}}
1414
1515
'
1616
headers:
@@ -27,7 +27,7 @@ interactions:
2727
content-type:
2828
- application/json
2929
method: POST
30-
uri: https://api.datadoghq.com/api/v2/team/cc3d71dc-cccd-11ed-ac3a-da7ad0900002/links
30+
uri: https://api.datadoghq.com/api/v2/team/5391cf72-ef4f-11ed-9b09-da7ad0900002/links
3131
response:
3232
body:
3333
string: '{"errors":["label cannot be empty"]}'
@@ -43,7 +43,7 @@ interactions:
4343
accept:
4444
- '*/*'
4545
method: DELETE
46-
uri: https://api.datadoghq.com/api/v2/team/cc3d71dc-cccd-11ed-ac3a-da7ad0900002
46+
uri: https://api.datadoghq.com/api/v2/team/5391cf72-ef4f-11ed-9b09-da7ad0900002
4747
response:
4848
body:
4949
string: ''
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-03-27T18:32:59.347Z
1+
2023-05-10T16:25:50.730Z

tests/v2/cassettes/test_scenarios/test_create_a_team_link_returns_ok_response.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"data":{"attributes":{"handle":"1679941979","name":"1679941979"},"type":"team"}}'
3+
body: '{"data":{"attributes":{"handle":"handle-afaf5e790c917aca","name":"name-afaf5e790c917aca"},"type":"team"}}'
44
headers:
55
accept:
66
- application/json
@@ -10,7 +10,7 @@ interactions:
1010
uri: https://api.datadoghq.com/api/v2/team
1111
response:
1212
body:
13-
string: '{"data":{"type":"team","id":"cceda3d6-cccd-11ed-aae5-da7ad0900002","attributes":{"name":"1679941979","handle":"1679941979","summary":null,"description":null,"color":0,"created_at":"2023-03-27T18:32:59.683291+00:00","modified_at":"2023-03-27T18:32:59.683295+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/cceda3d6-cccd-11ed-aae5-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/cceda3d6-cccd-11ed-aae5-da7ad0900002/permission-settings"}}}}}
13+
string: '{"data":{"type":"team","id":"53f8fe40-ef4f-11ed-b67f-da7ad0900002","attributes":{"name":"name-afaf5e790c917aca","handle":"handle-afaf5e790c917aca","summary":null,"description":null,"color":0,"created_at":"2023-05-10T16:25:50.863797+00:00","modified_at":"2023-05-10T16:25:50.863804+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/53f8fe40-ef4f-11ed-b67f-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/53f8fe40-ef4f-11ed-b67f-da7ad0900002/permission-settings"}}}}}
1414
1515
'
1616
headers:
@@ -27,10 +27,10 @@ interactions:
2727
content-type:
2828
- application/json
2929
method: POST
30-
uri: https://api.datadoghq.com/api/v2/team/cceda3d6-cccd-11ed-aae5-da7ad0900002/links
30+
uri: https://api.datadoghq.com/api/v2/team/53f8fe40-ef4f-11ed-b67f-da7ad0900002/links
3131
response:
3232
body:
33-
string: '{"data":{"type":"team_links","id":"cd25c6bc-cccd-11ed-830b-da7ad0900002","attributes":{"team_id":"cceda3d6-cccd-11ed-aae5-da7ad0900002","label":"Link
33+
string: '{"data":{"type":"team_links","id":"54179a26-ef4f-11ed-a9ba-da7ad0900002","attributes":{"team_id":"53f8fe40-ef4f-11ed-b67f-da7ad0900002","label":"Link
3434
label","url":"https://example.com","position":0}}}
3535
3636
'
@@ -46,7 +46,7 @@ interactions:
4646
accept:
4747
- '*/*'
4848
method: DELETE
49-
uri: https://api.datadoghq.com/api/v2/team/cceda3d6-cccd-11ed-aae5-da7ad0900002/links/cd25c6bc-cccd-11ed-830b-da7ad0900002
49+
uri: https://api.datadoghq.com/api/v2/team/53f8fe40-ef4f-11ed-b67f-da7ad0900002/links/54179a26-ef4f-11ed-a9ba-da7ad0900002
5050
response:
5151
body:
5252
string: ''
@@ -60,7 +60,7 @@ interactions:
6060
accept:
6161
- '*/*'
6262
method: DELETE
63-
uri: https://api.datadoghq.com/api/v2/team/cceda3d6-cccd-11ed-aae5-da7ad0900002
63+
uri: https://api.datadoghq.com/api/v2/team/53f8fe40-ef4f-11ed-b67f-da7ad0900002
6464
response:
6565
body:
6666
string: ''
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-03-27T18:33:01.052Z
1+
2023-05-10T16:25:51.602Z

tests/v2/cassettes/test_scenarios/test_create_a_team_returns_api_error_response_response.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"data":{"attributes":{"handle":"1679941981","name":"1679941981"},"type":"team"}}'
3+
body: '{"data":{"attributes":{"handle":"handle-8b8486a76bc6e6a1","name":"name-8b8486a76bc6e6a1"},"type":"team"}}'
44
headers:
55
accept:
66
- application/json
@@ -10,7 +10,7 @@ interactions:
1010
uri: https://api.datadoghq.com/api/v2/team
1111
response:
1212
body:
13-
string: '{"data":{"type":"team","id":"cddc7ff6-cccd-11ed-9329-da7ad0900002","attributes":{"name":"1679941981","handle":"1679941981","summary":null,"description":null,"color":11,"created_at":"2023-03-27T18:33:01.249180+00:00","modified_at":"2023-03-27T18:33:01.249185+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/cddc7ff6-cccd-11ed-9329-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/cddc7ff6-cccd-11ed-9329-da7ad0900002/permission-settings"}}}}}
13+
string: '{"data":{"type":"team","id":"547c6370-ef4f-11ed-9672-da7ad0900002","attributes":{"name":"name-8b8486a76bc6e6a1","handle":"handle-8b8486a76bc6e6a1","summary":null,"description":null,"color":9,"created_at":"2023-05-10T16:25:51.725343+00:00","modified_at":"2023-05-10T16:25:51.725347+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/547c6370-ef4f-11ed-9672-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/547c6370-ef4f-11ed-9672-da7ad0900002/permission-settings"}}}}}
1414
1515
'
1616
headers:
@@ -20,7 +20,8 @@ interactions:
2020
code: 201
2121
message: Created
2222
- request:
23-
body: '{"data":{"attributes":{"handle":"1679941981","name":"Example Team"},"relationships":{"users":{"data":[]}},"type":"team"}}'
23+
body: '{"data":{"attributes":{"handle":"handle-8b8486a76bc6e6a1","name":"Example
24+
Team"},"relationships":{"users":{"data":[]}},"type":"team"}}'
2425
headers:
2526
accept:
2627
- application/json
@@ -43,7 +44,7 @@ interactions:
4344
accept:
4445
- '*/*'
4546
method: DELETE
46-
uri: https://api.datadoghq.com/api/v2/team/cddc7ff6-cccd-11ed-9329-da7ad0900002
47+
uri: https://api.datadoghq.com/api/v2/team/547c6370-ef4f-11ed-9672-da7ad0900002
4748
response:
4849
body:
4950
string: ''

0 commit comments

Comments
 (0)