summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2018-04-02 17:55:00 +0200
committerGitHub <noreply@github.com>2018-04-02 17:55:00 +0200
commit0c96a53bb3495772193fd98ff18a0ded10128be3 (patch)
treecc53424049ee3b71c053fc03d30b17be9362b0ce /tests.py
parent3c621da9b77ee57dcfd42887b460e1ffb66528b2 (diff)
parentaae608237495fb63d9428da84f36db96d4e4c9dd (diff)
downloadpython-json-patch-0c96a53bb3495772193fd98ff18a0ded10128be3.tar.gz
Merge pull request #75 from stefankoegl/jsonptr
Expect path/from attributes also as JsonPoiner instances (#60)
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 548d28b..cd39b3b 100755
--- a/tests.py
+++ b/tests.py
@@ -608,6 +608,27 @@ class ConflictTests(unittest.TestCase):
self.assertRaises(jsonpatch.JsonPatchConflict, jsonpatch.apply_patch, src, patch_obj)
+class JsonPointerTests(unittest.TestCase):
+
+ def test_create_with_pointer(self):
+
+ patch = jsonpatch.JsonPatch([
+ {'op': 'add', 'path': jsonpointer.JsonPointer('/foo'), 'value': 'bar'},
+ {'op': 'add', 'path': jsonpointer.JsonPointer('/baz'), 'value': [1, 2, 3]},
+ {'op': 'remove', 'path': jsonpointer.JsonPointer('/baz/1')},
+ {'op': 'test', 'path': jsonpointer.JsonPointer('/baz'), 'value': [1, 3]},
+ {'op': 'replace', 'path': jsonpointer.JsonPointer('/baz/0'), 'value': 42},
+ {'op': 'remove', 'path': jsonpointer.JsonPointer('/baz/1')},
+ {'op': 'move', 'from': jsonpointer.JsonPointer('/foo'), 'path': jsonpointer.JsonPointer('/bar')},
+
+ ])
+ doc = {}
+ result = patch.apply(doc)
+ expected = {'bar': 'bar', 'baz': [42]}
+ self.assertEqual(result, expected)
+
+
+
if __name__ == '__main__':
modules = ['jsonpatch']
@@ -622,6 +643,7 @@ if __name__ == '__main__':
suite.addTest(unittest.makeSuite(InvalidInputTests))
suite.addTest(unittest.makeSuite(ConflictTests))
suite.addTest(unittest.makeSuite(OptimizationTests))
+ suite.addTest(unittest.makeSuite(JsonPointerTests))
return suite