Add test integ for predicates on number

This commit is contained in:
Fabrice Reix 2023-09-13 14:11:17 +02:00
parent 0dca370068
commit 8b322b9784
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
6 changed files with 81 additions and 0 deletions

View 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">&lt;=</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">&gt;</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">&gt;</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">&lt;=</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">&gt;</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">&gt;</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>

View 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
}

View 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}}}}]}

View File

@ -0,0 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl tests_ok/predicates_number.hurl --verbose

View 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",
)

View File

@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl tests_ok/predicates_number.hurl --verbose