Add integ test for jsonpath filter

This commit is contained in:
Fabrice Reix 2023-12-15 14:11:44 +01:00
parent 80159a8509
commit 1eeb340c30
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
2 changed files with 92 additions and 0 deletions

View File

@ -129,6 +129,59 @@ jsonpath "$.fruit.[?(@.US == 100)]" count == 0 # To be clarified with spec: th
]
}
GET http://localhost:8000/assert-json/filter-by-name
HTTP 200
[Asserts]
jsonpath "$..*[?(@.name)]" count == 5
jsonpath "$..*[?(@.name=='car')].id" nth 0 == 1
jsonpath "$..*[?(@.name=='wheel')].id" nth 0 == 4
jsonpath "$..items[?(@.name)]" count == 5
jsonpath "$..items[?(@.name=='car')].id" nth 0 == 1
jsonpath "$..items[?(@.name=='wheel')].id" nth 0 == 4
jsonpath "$.main.items[?(@.name)]" count == 3
jsonpath "$.main.items[?(@.name=='car')].id" nth 0 == 1
jsonpath "$.main.items[?(@.name=='wheel')].id" isEmpty
jsonpath "$.main..items[?(@.name)]" count == 4
jsonpath "$.main..items[?(@.name=='car')].id" nth 0 == 1
jsonpath "$.main..items[?(@.name=='wheel')].id" nth 0 == 4
{
"main": {
"items": [
{
"id": 1,
"name": "car"
},
{
"id": 2,
"name": "bike",
"items": [
{
"id": 4,
"name": "wheel"
}
]
},
{
"id": 3,
"name": "plane"
}
]
},
"more": {
"items": [
{
"id": 5,
"name": "scooter"
}
]
}
}
GET http://localhost:8000/assert-json/big-number
HTTP 200
[Asserts]

View File

@ -62,6 +62,45 @@ def assert_json_filter():
)
@app.route("/assert-json/filter-by-name")
def assert_json_filter_ny_name():
return Response(
"""{
"main": {
"items": [
{
"id": 1,
"name": "car"
},
{
"id": 2,
"name": "bike",
"items": [
{
"id": 4,
"name": "wheel"
}
]
},
{
"id": 3,
"name": "plane"
}
]
},
"more": {
"items": [
{
"id": 5,
"name": "scooter"
}
]
}
}""",
mimetype="application/json",
)
@app.route("/assert-json/big-number")
def assert_json_big_number():
return Response(