-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
read data from disk improvement (#251)
This commit adds a new feature that allows a user to specify a subset of a JSON file by using the existing JSONPath functionality by expanding on the read from disk operator '<@' closes #250 * add small warning about readability when using JSONPath from disk * Adds both unit and gabbit-based tests NOTE: * switching from str to six.string_types is necessary to handle encoded values.
- Loading branch information
1 parent
913cd94
commit 72256b0
Showing
6 changed files
with
161 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"values": [{ | ||
"pets": [{ | ||
"type": "cat", | ||
"sound": "meow" | ||
}, { | ||
"type": "dog", | ||
"sound": "woof" | ||
}] | ||
}, { | ||
"people": [{ | ||
"name": "chris", | ||
"id": 1 | ||
}, { | ||
"name": "justin", | ||
"id": 2 | ||
}] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Test loading expected data from file on disk with JSONPath | ||
# | ||
defaults: | ||
request_headers: | ||
content-type: application/json | ||
verbose: True | ||
|
||
tests: | ||
- name: json encoded value from disk | ||
POST: / | ||
data: <@data.json | ||
response_json_paths: | ||
$.foo['bár']: <@data.json:$.foo['bár'] | ||
|
||
- name: json parital from disk | ||
POST: / | ||
data: <@cat.json | ||
response_json_paths: | ||
$: <@pets.json:$[?type = "cat"] | ||
|
||
- name: json partial both sides | ||
POST: / | ||
data: <@pets.json | ||
response_json_paths: | ||
$[?type = "cat"].sound: <@values.json:$.values[0].pets[?type = "cat"].sound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"values": [{ | ||
"pets": [{ | ||
"type": "cat", | ||
"sound": "meow" | ||
}, { | ||
"type": "dog", | ||
"sound": "woof" | ||
}] | ||
}, { | ||
"people": [{ | ||
"name": "chris", | ||
"id": 1 | ||
}, { | ||
"name": "justin", | ||
"id": 2 | ||
}] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters