Skip to content

Commit 31f2cd3

Browse files
api-clients-generation-pipeline[bot]zippolyteci.datadog-api-spec
authored
Unskip python for metrics test (#491)
* Escape reserved keywords * record * Regenerate client from commit 6820788 of spec repo Co-authored-by: Hippolyte HENRY <[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 c892adb commit 31f2cd3

File tree

5 files changed

+79
-14
lines changed

5 files changed

+79
-14
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.4.1.dev8",
7-
"regenerated": "2021-06-21 16:53:58.937124",
8-
"spec_repo_commit": "609ca23"
7+
"regenerated": "2021-06-22 08:01:40.508539",
8+
"spec_repo_commit": "6820788"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-21 16:54:23.397056",
13-
"spec_repo_commit": "609ca23"
12+
"regenerated": "2021-06-22 08:02:06.972364",
13+
"spec_repo_commit": "6820788"
1414
}
1515
}
1616
}

tests/conftest.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ def pytest_configure(config):
7171
logging.basicConfig()
7272

7373

74+
def escape_reserved_keyword(word):
75+
"""
76+
# Escape reserved language keywords like openapi generator does it
77+
:param word: Word to escape
78+
:return: The escaped word if it was a reserved keyword, the word unchanged otherwise
79+
"""
80+
reserved_keywords = ["from"]
81+
if word in reserved_keywords:
82+
return f"_{word}"
83+
return word
84+
85+
7486
def pytest_bdd_before_step(request, feature, scenario, step, step_func):
7587
if tracer is None:
7688
return
@@ -158,12 +170,6 @@ def unique_lower(request, freezer):
158170
return f"{prefix}-{int(datetime.now().timestamp())}"
159171

160172

161-
@pytest.fixture
162-
def now(freezer):
163-
with freezer:
164-
return datetime.now()
165-
166-
167173
def relative_time(freezer, iso):
168174
time_re = re.compile(r"now( *([+-]) *(\d+)([smhdMy]))?")
169175

@@ -376,14 +382,14 @@ def request_body_from_file(context, path, package_name):
376382
@given(parsers.parse('request contains "{name}" parameter from "{path}"'))
377383
def request_parameter(context, name, path):
378384
"""Set request parameter."""
379-
context["api_request"]["kwargs"][snake_case(name)] = glom(context, path)
385+
context["api_request"]["kwargs"][escape_reserved_keyword(snake_case(name))] = glom(context, path)
380386

381387

382388
@given(parsers.parse('request contains "{name}" parameter with value {value}'))
383389
def request_parameter_with_value(context, name, value):
384390
"""Set request parameter."""
385391
tpl = Template(value).render(**context)
386-
context["api_request"]["kwargs"][snake_case(name)] = json.loads(tpl)
392+
context["api_request"]["kwargs"][escape_reserved_keyword(snake_case(name))] = json.loads(tpl)
387393

388394

389395
def build_given(version, operation):
@@ -414,7 +420,9 @@ def build_param(p):
414420
if "source" in p:
415421
return glom(context, p["source"])
416422

417-
kwargs = {snake_case(p["name"]): build_param(p) for p in operation.get("parameters", [])}
423+
kwargs = {
424+
escape_reserved_keyword(snake_case(p["name"])): build_param(p) for p in operation.get("parameters", [])
425+
}
418426
kwargs["_check_input_type"] = False
419427
result = operation_method(**kwargs)
420428
client.last_response.urllib3_response.close()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2021-06-21T16:05:21.376427+02:00
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
- QueryMetrics
11+
User-Agent:
12+
- datadog-api-client-python/1.0.0b8.dev19+dirty (python 3.9.2; os Darwin; arch
13+
x86_64)
14+
method: GET
15+
uri: https://api.datadoghq.com/api/v1/query?from=1624197921&query=system.cpu.idle%7B%2A%7D&to=1624284321
16+
response:
17+
body:
18+
string: '{"status":"ok","resp_version":1,"series":[{"end":1624284599000,"attributes":{},"metric":"system.cpu.idle","interval":300,"tag_set":[],"start":1624198200000,"length":288,"query_index":0,"aggr":null,"scope":"*","pointlist":[[1624198200000.0,94.39813191320759],[1624198500000.0,94.19734655290642],[1624198800000.0,94.53104766743296],[1624199100000.0,94.39338729858399],[1624199400000.0,94.28765021006267],[1624199700000.0,94.41133007049561],[1624200000000.0,94.36866771697999],[1624200300000.0,94.17877393086751],[1624200600000.0,94.40067696889241],[1624200900000.0,94.48034049987793],[1624201200000.0,94.23829783121745],[1624201500000.0,94.55879801432292],[1624201800000.0,94.41020482381185],[1624202100000.0,94.17601174672444],[1624202400000.0,94.50936250428896],[1624202700000.0,94.35845012792805],[1624203000000.0,94.1425629679362],[1624203300000.0,94.38366920471191],[1624203600000.0,94.3300105158488],[1624203900000.0,94.21123137156168],[1624204200000.0,94.31483924865722],[1624204500000.0,94.34877431233724],[1624204800000.0,94.01880969617191],[1624205100000.0,94.30536037445069],[1624205400000.0,94.32441084543863],[1624205700000.0,94.30827509562174],[1624206000000.0,94.58611968994141],[1624206300000.0,94.5401071548462],[1624206600000.0,94.28349614461263],[1624206900000.0,94.52987126668295],[1624207200000.0,94.47673160117745],[1624207500000.0,94.32281352996826],[1624207800000.0,94.49645055135092],[1624208100000.0,94.46365501403808],[1624208400000.0,94.29581184387207],[1624208700000.0,94.42285628000896],[1624209000000.0,94.40819746653239],[1624209300000.0,94.41905760366383],[1624209600000.0,94.2623280582812],[1624209900000.0,94.39951443990071],[1624210200000.0,94.39618459065755],[1624210500000.0,94.19432697296142],[1624210800000.0,94.3851450284322],[1624211100000.0,94.42814743758848],[1624211400000.0,94.20812718073527],[1624211700000.0,94.4195305633545],[1624212000000.0,94.40055303573608],[1624212300000.0,94.21232818603515],[1624212600000.0,94.43321462925648],[1624212900000.0,94.38465650558472],[1624213200000.0,94.29069885889689],[1624213500000.0,94.32821983973186],[1624213800000.0,94.54919144269583],[1624214100000.0,94.44013894399008],[1624214400000.0,94.23421207427978],[1624214700000.0,94.40935446421305],[1624215000000.0,94.37507056554159],[1624215300000.0,94.1969519551595],[1624215600000.0,94.33373622894287],[1624215900000.0,94.3899260075887],[1624216200000.0,94.14111427942912],[1624216500000.0,94.35470384597778],[1624216800000.0,94.37933494900697],[1624217100000.0,94.32067985792418],[1624217400000.0,94.36004475911459],[1624217700000.0,94.42445730764332],[1624218000000.0,94.35375923156738],[1624218300000.0,94.21220576604208],[1624218600000.0,94.40773817698161],[1624218900000.0,94.42312907536825],[1624219200000.0,94.17845507756175],[1624219500000.0,94.30888440450032],[1624219800000.0,94.29754856109619],[1624220100000.0,94.10676900227864],[1624220400000.0,94.34170137405395],[1624220700000.0,94.27294328689575],[1624221000000.0,94.12007799724604],[1624221300000.0,94.23532651901245],[1624221600000.0,94.26119674682617],[1624221900000.0,94.12345672607422],[1624222200000.0,94.18381929397583],[1624222500000.0,94.40041382040754],[1624222800000.0,94.28615033467611],[1624223100000.0,94.17970895767212],[1624223400000.0,94.35907029469809],[1624223700000.0,94.35254409790039],[1624224000000.0,94.18402439117432],[1624224300000.0,94.35143922639374],[1624224600000.0,94.34978422164917],[1624224900000.0,94.22333980895378],[1624225200000.0,94.34537547567616],[1624225500000.0,94.32154823789661],[1624225800000.0,94.11763894637959],[1624226100000.0,94.3128286743164],[1624226400000.0,94.31227086854462],[1624226700000.0,94.31530167897542],[1624227000000.0,94.10079242070516],[1624227300000.0,94.34136527379354],[1624227600000.0,94.36030803044638],[1624227900000.0,94.17436892827352],[1624228200000.0,94.36315196990967],[1624228500000.0,94.39243394096425],[1624228800000.0,94.29789796193441],[1624229100000.0,94.46178727467854],[1624229400000.0,94.44924701690674],[1624229700000.0,94.28952174858759],[1624230000000.0,94.35877183278402],[1624230300000.0,94.350108063461],[1624230600000.0,94.14599849065145],[1624230900000.0,94.36164511362712],[1624231200000.0,94.40806637194332],[1624231500000.0,94.31411820729573],[1624231800000.0,94.37794653574626],[1624232100000.0,94.4946735827128],[1624232400000.0,94.4362469736735],[1624232700000.0,94.43119422912598],[1624233000000.0,94.50784362792969],[1624233300000.0,94.55712063680559],[1624233600000.0,94.32067376454671],[1624233900000.0,94.52862218221028],[1624234200000.0,94.54402097066243],[1624234500000.0,94.2978920520552],[1624234800000.0,94.55089467366537],[1624235100000.0,94.49035120646158],[1624235400000.0,94.35094590504964],[1624235700000.0,94.49819083501829],[1624236000000.0,94.53300047556559],[1624236300000.0,94.36831115722656],[1624236600000.0,94.61964148963058],[1624236900000.0,94.48652102152506],[1624237200000.0,94.41590251922608],[1624237500000.0,94.55242470833768],[1624237800000.0,94.43662044525146],[1624238100000.0,94.44240445454915],[1624238400000.0,94.55640191199795],[1624238700000.0,94.43188676258062],[1624239000000.0,94.57894620259603],[1624239300000.0,94.59796852111816],[1624239600000.0,94.37453506469727],[1624239900000.0,94.56245500976975],[1624240200000.0,94.5595696258545],[1624240500000.0,94.35786156972249],[1624240800000.0,94.44670319875081],[1624241100000.0,94.4984917195638],[1624241400000.0,94.35571534474691],[1624241700000.0,94.53033972422281],[1624242000000.0,94.49662693023681],[1624242300000.0,94.33347611745198],[1624242600000.0,94.47473242441814],[1624242900000.0,94.52436120351156],[1624243200000.0,94.32633979797363],[1624243500000.0,94.51864741007488],[1624243800000.0,94.53917877197266],[1624244100000.0,94.44294651031494],[1624244400000.0,94.47781599680583],[1624244700000.0,94.591730372111],[1624245000000.0,94.3864792251587],[1624245300000.0,94.51336411794027],[1624245600000.0,94.5814111328125],[1624245900000.0,94.442891553243],[1624246200000.0,94.6004889678955],[1624246500000.0,94.62472353685622],[1624246800000.0,94.46381968180339],[1624247100000.0,94.56400960883838],[1624247400000.0,94.5116028753703],[1624247700000.0,94.40951285044352],[1624248000000.0,94.46025210457879],[1624248300000.0,94.5891160329183],[1624248600000.0,94.40720461527506],[1624248900000.0,94.62797856648763],[1624249200000.0,94.55705033620198],[1624249500000.0,94.4171111599711],[1624249800000.0,94.5649408976237],[1624250100000.0,94.59302628835043],[1624250400000.0,94.40381062825521],[1624250700000.0,94.56383366902669],[1624251000000.0,94.512487590713],[1624251300000.0,94.49076393946706],[1624251600000.0,94.55306349436442],[1624251900000.0,94.61997992197672],[1624252200000.0,94.39521850585938],[1624252500000.0,94.63254063924154],[1624252800000.0,94.61739616394043],[1624253100000.0,94.4381905110677],[1624253400000.0,94.57049737294516],[1624253700000.0,94.62282103220622],[1624254000000.0,94.46019727071126],[1624254300000.0,94.62722661336262],[1624254600000.0,94.49526218414307],[1624254900000.0,94.49414165496826],[1624255200000.0,94.48376508367141],[1624255500000.0,94.41269858042399],[1624255800000.0,94.47455055236816],[1624256100000.0,94.54946206410726],[1624256400000.0,94.37961058648641],[1624256700000.0,94.57892716725668],[1624257000000.0,94.52012396494547],[1624257300000.0,94.39014829085177],[1624257600000.0,94.53190947214762],[1624257900000.0,94.52667250315348],[1624258200000.0,94.34014271729744],[1624258500000.0,94.56757110595703],[1624258800000.0,94.50326159159343],[1624259100000.0,94.44231212615966],[1624259400000.0,94.56969860076904],[1624259700000.0,94.62054849150996],[1624260000000.0,94.44772904713949],[1624260300000.0,94.67902959187826],[1624260600000.0,94.53254865053978],[1624260900000.0,93.23454173130972],[1624261200000.0,94.54087286162795],[1624261500000.0,93.40130131212],[1624261800000.0,93.82373073140128],[1624262100000.0,93.97671058529713],[1624262400000.0,94.31595488726083],[1624262700000.0,94.60536967097102],[1624263000000.0,93.7156607703245],[1624263300000.0,94.18309879969884],[1624263600000.0,93.43807558996694],[1624263900000.0,93.94995867453541],[1624264200000.0,93.95490699065358],[1624264500000.0,94.74956823278356],[1624264800000.0,94.841411819458],[1624265100000.0,94.82648165914036],[1624265400000.0,94.84221773783366],[1624265700000.0,94.83365384419758],[1624266000000.0,94.823230565389],[1624266300000.0,94.7082103311199],[1624266600000.0,94.51795727726542],[1624266900000.0,92.8859915352593],[1624267200000.0,93.60880860285972],[1624267500000.0,93.6121302156259],[1624267800000.0,94.35958441201743],[1624268100000.0,93.75439928559696],[1624268400000.0,94.49032126835414],[1624268700000.0,94.50063208710375],[1624269000000.0,94.39538184574673],[1624269300000.0,94.48240451536317],[1624269600000.0,94.58328719104794],[1624269900000.0,94.31521091461181],[1624270200000.0,94.32565647622813],[1624270500000.0,94.44019813537598],[1624270800000.0,94.43282942090715],[1624271100000.0,94.45625738416399],[1624271400000.0,94.53466883992654],[1624271700000.0,93.70765121915349],[1624272000000.0,94.02593599332796],[1624272300000.0,93.26637262126566],[1624272600000.0,93.44899265878152],[1624272900000.0,94.16846224341062],[1624273200000.0,94.25320138158025],[1624273500000.0,94.66048970540365],[1624273800000.0,94.68106206258138],[1624274100000.0,94.6199148050944],[1624274400000.0,94.61410266440987],[1624274700000.0,94.53758878072102],[1624275000000.0,94.52862988789876],[1624275300000.0,94.62290079752604],[1624275600000.0,94.55521260579427],[1624275900000.0,94.63284960428874],[1624276200000.0,94.57518697102864],[1624276500000.0,94.60668299357097],[1624276800000.0,94.57455609639486],[1624277100000.0,94.60967163085938],[1624277400000.0,94.61262311299642],[1624277700000.0,94.64866181440577],[1624278000000.0,94.59137641059027],[1624278300000.0,94.66656238968308],[1624278600000.0,94.66961759528857],[1624278900000.0,94.69902832236066],[1624279200000.0,94.68822303771972],[1624279500000.0,94.7019780476888],[1624279800000.0,94.6036553862911],[1624280100000.0,94.5736270904541],[1624280400000.0,94.58613873799642],[1624280700000.0,94.64104354858398],[1624281000000.0,94.63798931211133],[1624281300000.0,94.6777589670817],[1624281600000.0,94.61854910451832],[1624281900000.0,94.61167597366591],[1624282200000.0,94.6652087656657],[1624282500000.0,94.64990764336298],[1624282800000.0,94.65381436665852],[1624283100000.0,94.58915603637695],[1624283400000.0,94.62302862077752],[1624283700000.0,94.60559338887532],[1624284000000.0,94.57403697138247],[1624284300000.0,95.8333757188585]],"expression":"system.cpu.idle{*}","unit":[{"family":"percentage","scale_factor":1.0,"name":"percent","short_name":"%","plural":"percent","id":17},null],"display_name":"system.cpu.idle"}],"to_date":1624284321000,"query":"system.cpu.idle{*}","message":"","res_type":"time_series","times":[],"from_date":1624197921000,"group_by":[],"values":[]}'
19+
headers:
20+
Connection:
21+
- keep-alive
22+
Content-Length:
23+
- '10884'
24+
Content-Type:
25+
- application/json
26+
Date:
27+
- Mon, 21 Jun 2021 14:05:22 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-debug:
41+
- 7vnP2Oxw2WcQZuDbLt/W2sw+5aqazKiohrNDUtLRFu5RSYZ9uhZCton20e/73ldZ
42+
x-dd-version:
43+
- '35.4795120'
44+
x-frame-options:
45+
- SAMEORIGIN
46+
x-ratelimit-limit:
47+
- '1600'
48+
x-ratelimit-period:
49+
- '3600'
50+
x-ratelimit-remaining:
51+
- '1598'
52+
x-ratelimit-reset:
53+
- '3279'
54+
status:
55+
code: 200
56+
message: OK
57+
version: 1

tests/v1/features/metrics.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Feature: Metrics
7777
When the request is sent
7878
Then the response status is 400 Bad Request
7979

80-
@skip-python
8180
Scenario: Query timeseries points returns "OK" response
8281
Given a valid "appKeyAuth" key in the system
8382
And new "QueryMetrics" request

0 commit comments

Comments
 (0)