mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-22 15:42:20 +03:00
Update variables.hurl integration test.
We can define multiple variables in [Options] section. Contrary to other options, variables defined on this request are still available to following entries.
This commit is contained in:
parent
c39b6a8494
commit
28b5a49c1d
@ -1 +1,3 @@
|
||||
curl -H 'Name: Jennifer' -H 'Age: 30' -H 'Height: 1.7' -H 'Female: true' -H 'Id: 123' -H 'A_Null: null' -H 'Country: Italy' -H 'Content-Type: application/json' --data $'{\n "name": "Jennifer",\n "age": 30,\n "height": 1.7,\n "female": true,\n "id": "123",\n "a_null": null,\n "country": "Italy"\n}' 'http://localhost:8000/variables'
|
||||
curl -H 'Name: Jennifer' -H 'Age: 30' -H 'Height: 1.7' -H 'Female: true' -H 'Id: 123' -H 'A_Null: null' -H 'Country: Italy' -H 'Planet: The Earth' -H 'Content-Type: application/json' --data $'{\n "name": "Jennifer",\n "age": 30,\n "height": 1.7,\n "female": true,\n "id": "123",\n "a_null": null,\n "country": "Italy",\n "planet": "The Earth"\n}' 'http://localhost:8000/variables'
|
||||
curl 'http://localhost:8000/variable/country'
|
||||
curl 'http://localhost:8000/variable/planet'
|
||||
|
@ -12,8 +12,10 @@
|
||||
<span class="line"><span class="string">Id</span><span>:</span> <span class="string">{{my-id}}</span></span>
|
||||
<span class="line"><span class="string">A_Null</span><span>:</span> <span class="string">{{a_null}}</span></span>
|
||||
<span class="line"><span class="string">Country</span><span>:</span> <span class="string">{{country}}</span></span>
|
||||
<span class="line"><span class="string">Planet</span><span>:</span> <span class="string">{{planet}}</span></span>
|
||||
<span class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">variable</span><span>:</span> country<span>=</span><span class="string">Italy</span></span>
|
||||
<span class="line"><span class="string">variable</span><span>:</span> planet<span>=</span><span class="string">The Earth</span></span>
|
||||
<span class="json"><span class="line">{</span>
|
||||
<span class="line"> "name": "{{name}}",</span>
|
||||
<span class="line"> "age": {{age}},</span>
|
||||
@ -21,7 +23,8 @@
|
||||
<span class="line"> "female": {{female}},</span>
|
||||
<span class="line"> "id": "{{my-id}}",</span>
|
||||
<span class="line"> "a_null": {{a_null}},</span>
|
||||
<span class="line"> "country": "{{country}}"</span>
|
||||
<span class="line"> "country": "{{country}}",</span>
|
||||
<span class="line"> "planet": "{{planet}}"</span>
|
||||
<span class="line">}</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
@ -33,4 +36,17 @@
|
||||
<span class="line"><span class="query-type">variable</span> <span class="string">"a_null"</span> <span class="predicate-type">==</span> <span class="null">null</span></span>
|
||||
<span class="line"><span class="query-type">variable</span> <span class="string">"my-id"</span> <span class="predicate-type">==</span> <span class="string">"123"</span></span>
|
||||
<span class="line"><span class="query-type">variable</span> <span class="string">"country"</span> <span class="predicate-type">==</span> <span class="string">"Italy"</span></span>
|
||||
<span class="line"><span class="query-type">variable</span> <span class="string">"planet"</span> <span class="predicate-type">==</span> <span class="string">"The Earth"</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"></span><span class="comment"># `country` and `planet` variable are still available</span>
|
||||
<span class="line"></span><span class="comment"># for the next entries, even if they've been defined in the</span>
|
||||
<span class="line"></span><span class="comment"># previous `[Options]` request section.</span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/variable/country</span></span>
|
||||
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
<span class="line"><span class="string">`{{country}}`</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/variable/planet</span></span>
|
||||
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
<span class="line"><span class="string">`{{planet}}`</span></span>
|
||||
</span></span></code></pre>
|
||||
|
@ -12,8 +12,10 @@ Female: {{female}}
|
||||
Id: {{my-id}}
|
||||
A_Null: {{a_null}}
|
||||
Country: {{country}}
|
||||
Planet: {{planet}}
|
||||
[Options]
|
||||
variable: country=Italy
|
||||
variable: planet=The Earth
|
||||
{
|
||||
"name": "{{name}}",
|
||||
"age": {{age}},
|
||||
@ -21,7 +23,8 @@ variable: country=Italy
|
||||
"female": {{female}},
|
||||
"id": "{{my-id}}",
|
||||
"a_null": {{a_null}},
|
||||
"country": "{{country}}"
|
||||
"country": "{{country}}",
|
||||
"planet": "{{planet}}"
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
@ -33,3 +36,16 @@ variable "height" == 1.70
|
||||
variable "a_null" == null
|
||||
variable "my-id" == "123"
|
||||
variable "country" == "Italy"
|
||||
variable "planet" == "The Earth"
|
||||
|
||||
|
||||
# `country` and `planet` variable are still available
|
||||
# for the next entries, even if they've been defined in the
|
||||
# previous `[Options]` request section.
|
||||
GET http://localhost:8000/variable/country
|
||||
HTTP 200
|
||||
`{{country}}`
|
||||
|
||||
GET http://localhost:8000/variable/planet
|
||||
HTTP 200
|
||||
`{{planet}}`
|
||||
|
@ -1 +1 @@
|
||||
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/variables","headers":[{"name":"Name","value":"{{name}}"},{"name":"Age","value":"{{age}}"},{"name":"Height","value":"{{height}}"},{"name":"Female","value":"{{female}}"},{"name":"Id","value":"{{my-id}}"},{"name":"A_Null","value":"{{a_null}}"},{"name":"Country","value":"{{country}}"}],"body":{"type":"json","value":{"name":"{{name}}","age":"{{age}}","height":"{{height}}","female":"{{female}}","id":"{{my-id}}","a_null":"{{a_null}}","country":"{{country}}"}}},"response":{"status":200,"asserts":[{"query":{"type":"variable","name":"name"},"predicate":{"type":"equal","value":"Jennifer"}},{"query":{"type":"variable","name":"female"},"predicate":{"type":"equal","value":true}},{"query":{"type":"variable","name":"age"},"predicate":{"type":"equal","value":30}},{"query":{"type":"variable","name":"height"},"predicate":{"type":"equal","value":1.70}},{"query":{"type":"variable","name":"a_null"},"predicate":{"type":"equal","value":null}},{"query":{"type":"variable","name":"my-id"},"predicate":{"type":"equal","value":"123"}},{"query":{"type":"variable","name":"country"},"predicate":{"type":"equal","value":"Italy"}}]}}]}
|
||||
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/variables","headers":[{"name":"Name","value":"{{name}}"},{"name":"Age","value":"{{age}}"},{"name":"Height","value":"{{height}}"},{"name":"Female","value":"{{female}}"},{"name":"Id","value":"{{my-id}}"},{"name":"A_Null","value":"{{a_null}}"},{"name":"Country","value":"{{country}}"},{"name":"Planet","value":"{{planet}}"}],"body":{"type":"json","value":{"name":"{{name}}","age":"{{age}}","height":"{{height}}","female":"{{female}}","id":"{{my-id}}","a_null":"{{a_null}}","country":"{{country}}","planet":"{{planet}}"}}},"response":{"status":200,"asserts":[{"query":{"type":"variable","name":"name"},"predicate":{"type":"equal","value":"Jennifer"}},{"query":{"type":"variable","name":"female"},"predicate":{"type":"equal","value":true}},{"query":{"type":"variable","name":"age"},"predicate":{"type":"equal","value":30}},{"query":{"type":"variable","name":"height"},"predicate":{"type":"equal","value":1.70}},{"query":{"type":"variable","name":"a_null"},"predicate":{"type":"equal","value":null}},{"query":{"type":"variable","name":"my-id"},"predicate":{"type":"equal","value":"123"}},{"query":{"type":"variable","name":"country"},"predicate":{"type":"equal","value":"Italy"}},{"query":{"type":"variable","name":"planet"},"predicate":{"type":"equal","value":"The Earth"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/variable/country"},"response":{"status":200,"body":{"type":"text","value":"{{country}}"}}},{"request":{"method":"GET","url":"http://localhost:8000/variable/planet"},"response":{"status":200,"body":{"type":"text","value":"{{planet}}"}}}]}
|
||||
|
@ -13,6 +13,7 @@ def variables():
|
||||
assert request.headers["Height"] == "1.7"
|
||||
assert request.headers["A_null"] == "null"
|
||||
assert request.headers["Country"] == "Italy"
|
||||
assert request.headers["Planet"] == "The Earth"
|
||||
|
||||
s = request.data.decode("utf-8")
|
||||
data = json.loads(s)
|
||||
@ -23,4 +24,15 @@ def variables():
|
||||
assert data["height"] == 1.7
|
||||
assert data["a_null"] is None
|
||||
assert data["country"] == "Italy"
|
||||
assert data["planet"] == "The Earth"
|
||||
return ""
|
||||
|
||||
|
||||
@app.route("/variable/country")
|
||||
def country():
|
||||
return "Italy"
|
||||
|
||||
|
||||
@app.route("/variable/planet")
|
||||
def planet():
|
||||
return "The Earth"
|
||||
|
Loading…
Reference in New Issue
Block a user