Documentation for <@ in json path values

While writing the documentation it was discovered an additional
test case was needed, so that is added here. It tests partial
chunks of JSON.
This commit is contained in:
Chris Dent 2017-07-07 10:58:09 +01:00
parent 09391d2e31
commit 92377f8ada
4 changed files with 43 additions and 0 deletions

View File

@ -64,8 +64,23 @@ lead to difficult to read tests and it also indicates that your
gabbi tests are being used to test your serializers and data models,
not just your API interactions.
It is also possible to read raw JSON from disk for either all or
some of a JSON response::
response_json_paths:
$: @<data.json
or::
response_json_paths:
$.pets: <@pets.json
$.pets[0]: <@cat.json
Examples like this can be found in one of gabbi's `own tests`_.
There are more JSONPath examples in :doc:`example` and in the
`jsonpath_rw`_ and `jsonpath_rw_ext`_ documentation.
.. _jsonpath_rw: http://jsonpath-rw.readthedocs.io/en/latest/
.. _jsonpath_rw_ext: https://python-jsonpath-rw-ext.readthedocs.io/en/latest/
.. _own tests: https://github.com/cdent/gabbi/blob/master/gabbi/tests/gabbits_intercept/data.yaml

View File

@ -0,0 +1,4 @@
{
"type": "cat",
"sound": "meow"
}

View File

@ -58,3 +58,17 @@ tests:
response_json_paths:
foo['bár']: 1
$: <@data.json
- name: partial json from disk
POST: /
request_headers:
content-type: application/json
data:
pets:
- type: cat
sound: meow
- type: dog
sound: woof
response_json_paths:
$.pets: <@pets.json
$.pets[0]: <@cat.json

View File

@ -0,0 +1,10 @@
[
{
"type": "cat",
"sound": "meow"
},
{
"type": "dog",
"sound": "woof"
}
]