mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2025-01-02 07:56:31 +03:00
Add test integ for predicates on number
This commit is contained in:
parent
0dca370068
commit
8b322b9784
31
integration/tests_ok/predicates_number.html
Normal file
31
integration/tests_ok/predicates_number.html
Normal file
@ -0,0 +1,31 @@
|
||||
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># testing predicates</span>
|
||||
<span class="line"></span><span class="comment"># on the number types: integer and float</span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/predicates-number</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
<span class="line"><span class="section-header">[Asserts]</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">exists</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">isInteger</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="not">not</span> <span class="predicate-type">isFloat</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">==</span> <span class="number">1</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type"><=</span> <span class="number">2</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">></span> <span class="number">0</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">></span> <span class="number">0.0</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">!=</span> <span class="null">null</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">exists</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">isFloat</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="not">not</span> <span class="predicate-type">isInteger</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">==</span> <span class="number">1.0</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type"><=</span> <span class="number">2.0</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">></span> <span class="number">0.0</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">></span> <span class="number">0</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">!=</span> <span class="null">null</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="json"><span class="line">{</span>
|
||||
<span class="line"> "integer": 1,</span>
|
||||
<span class="line"> "float": 1.0</span>
|
||||
<span class="line">}</span></span>
|
||||
</span></span><span class="line"></span>
|
||||
</code></pre>
|
30
integration/tests_ok/predicates_number.hurl
Normal file
30
integration/tests_ok/predicates_number.hurl
Normal file
@ -0,0 +1,30 @@
|
||||
# testing predicates
|
||||
# on the number types: integer and float
|
||||
GET http://localhost:8000/predicates-number
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
|
||||
jsonpath "$.integer" exists
|
||||
jsonpath "$.integer" isInteger
|
||||
jsonpath "$.integer" not isFloat
|
||||
jsonpath "$.integer" == 1
|
||||
jsonpath "$.integer" <= 2
|
||||
jsonpath "$.integer" > 0
|
||||
jsonpath "$.integer" > 0.0
|
||||
jsonpath "$.integer" != null
|
||||
|
||||
jsonpath "$.float" exists
|
||||
jsonpath "$.float" isFloat
|
||||
jsonpath "$.float" not isInteger
|
||||
jsonpath "$.float" == 1.0
|
||||
jsonpath "$.float" <= 2.0
|
||||
jsonpath "$.float" > 0.0
|
||||
jsonpath "$.float" > 0
|
||||
jsonpath "$.float" != null
|
||||
|
||||
{
|
||||
"integer": 1,
|
||||
"float": 1.0
|
||||
}
|
||||
|
1
integration/tests_ok/predicates_number.json
Normal file
1
integration/tests_ok/predicates_number.json
Normal file
@ -0,0 +1 @@
|
||||
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/predicates-number"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"isInteger"}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"not":true,"type":"isFloat"}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"equal","value":1}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"less-or-equal","value":2}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"greater","value":0}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"greater","value":0.0}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"not-equal","value":null}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"isFloat"}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"not":true,"type":"isInteger"}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"equal","value":1.0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"less-or-equal","value":2.0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"greater","value":0.0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"greater","value":0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"not-equal","value":null}}],"body":{"type":"json","value":{"integer":1,"float":1.0}}}}]}
|
3
integration/tests_ok/predicates_number.ps1
Normal file
3
integration/tests_ok/predicates_number.ps1
Normal file
@ -0,0 +1,3 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
hurl tests_ok/predicates_number.hurl --verbose
|
13
integration/tests_ok/predicates_number.py
Normal file
13
integration/tests_ok/predicates_number.py
Normal file
@ -0,0 +1,13 @@
|
||||
from app import app
|
||||
from flask import Response
|
||||
|
||||
|
||||
@app.route("/predicates-number")
|
||||
def predicates_number():
|
||||
return Response(
|
||||
"""{
|
||||
"integer": 1,
|
||||
"float": 1.0
|
||||
}""",
|
||||
mimetype="application/json",
|
||||
)
|
3
integration/tests_ok/predicates_number.sh
Executable file
3
integration/tests_ok/predicates_number.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
hurl tests_ok/predicates_number.hurl --verbose
|
Loading…
Reference in New Issue
Block a user