ref current spec, add its new test case

the updated spec [1] didn't change anything that would make a new version of
python-json-patch necessary. This commit only updates the reference to the
current version, and adds a new example

[1] http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03
This commit is contained in:
Stefan Kögl
2012-09-05 17:21:43 +02:00
parent ffd125cd89
commit 5480cc5a8b
2 changed files with 11 additions and 1 deletions

View File

@@ -31,7 +31,7 @@
# #
"""Apply JSON-Patches according to """Apply JSON-Patches according to
http://tools.ietf.org/html/draft-pbryan-json-patch-04""" http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03"""
# Will be parsed by setup.py to determine package metadata # Will be parsed by setup.py to determine package metadata
__author__ = 'Stefan Kögl <stefan@skoegl.net>' __author__ = 'Stefan Kögl <stefan@skoegl.net>'

View File

@@ -133,6 +133,16 @@ class MakePatchTestCase(unittest.TestCase):
res = patch.apply(src) res = patch.apply(src)
self.assertEqual(res, dst) self.assertEqual(res, dst)
def test_add_nested(self):
# see http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03#appendix-A.10
src = {"foo": "bar"}
patch_obj = [ { "add": "/child", "value": { "grandchild": { } } } ]
res = jsonpatch.apply_patch(src, patch_obj)
expected = { "foo": "bar",
"child": { "grandchild": { } }
}
self.assertEqual(expected, res)
def suite(): def suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(jsonpatch)) suite.addTest(doctest.DocTestSuite(jsonpatch))