Skip to content

Commit

Permalink
Support jsonpointer >= 0.6. Closes #11.
Browse files Browse the repository at this point in the history
  • Loading branch information
peritus committed Jan 6, 2013
1 parent 60ca9fa commit aa83809
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ mostly a wrapper supposed to have a nice API)!
Changelog
---------

**v0.3.4**

- Add support for python-json-pointer >= 0.6 (if you experienced
"``AttributeError: 'module' object has no attribute 'set_pointer'``", you
should upgrade to this version).

**v0.3.3**

- add HTTPS support
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
zip_safe = False,
classifiers = CLASSIFIERS.splitlines(),
package_dir = {'' : 'src'},
install_requires = ['robotframework', 'webtest', 'jsonpointer'],
install_requires = ['robotframework', 'webtest', 'jsonpatch==0.12', 'jsonpointer==0.7'],
packages = ['HttpLibrary']
)
9 changes: 6 additions & 3 deletions src/HttpLibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import livetest
import json
import jsonpointer
import jsonpatch

def load_json(json_string):
try:
Expand Down Expand Up @@ -581,9 +582,11 @@ def set_json_value(self, json_string, json_pointer, json_value):
| ${result}= | Set Json Value | {"foo": {"bar": [1,2,3]}} | /foo | 12 |
| Should Be Equal | ${result} | {"foo": 12} | | |
"""
value = load_json(json_value)
p = jsonpointer.set_pointer(json_string, json_pointer, value)
return json_string
return jsonpatch.apply_patch(json_string, [{
'op': 'add',
'path': json_pointer,
'value': load_json(json_value)
}])

@_with_json
def log_json(self, json_string, log_level='INFO'):
Expand Down
4 changes: 2 additions & 2 deletions tests/json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Get Json Value OK
Get Json Value Fail
Set Test Variable ${obj} {"foo":{"another prop":{"baz":"A string"}}}
Run Keyword And Expect Error
... JsonPointerException: 'bar' not found in {u'baz': u'A string'}
... JsonPointerException: member 'bar' not found in {u'baz': u'A string'}
... Get Json Value ${obj} /foo/another%20prop/bar

Get Json Value Documentation
Expand Down Expand Up @@ -94,7 +94,7 @@ Json Value Should Be Fail
Json Value Should Be Fail Invalid Pointer
Set Test Variable ${doc} {"foo": {"bar": [4,5,6]}}
Run Keyword And Expect Error
... JsonPointerException: 'baz' not found in {u'foo': {u'bar': [4, 5, 6]}}
... JsonPointerException: member 'baz' not found in {u'foo': {u'bar': [4, 5, 6]}}
... Json Value Should Equal ${doc} /baz [7,8,9]

Stringify Documentation Example
Expand Down

0 comments on commit aa83809

Please sign in to comment.