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:
parent
09391d2e31
commit
92377f8ada
|
@ -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
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"type": "cat",
|
||||
"sound": "meow"
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"type": "cat",
|
||||
"sound": "meow"
|
||||
},
|
||||
{
|
||||
"type": "dog",
|
||||
"sound": "woof"
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue