diff options
author | Stefan Kögl <stefan@skoegl.net> | 2017-12-03 23:02:18 +0100 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2017-12-03 23:02:18 +0100 |
commit | aae608237495fb63d9428da84f36db96d4e4c9dd (patch) | |
tree | 459ebd258b9aae7bd5e88d216c6a45dcd222d62a /tests.py | |
parent | df0c56d592c9f1d0fada201b7fa66d9d359ac7a3 (diff) | |
download | python-json-patch-jsonptr.tar.gz |
Expect path/from attributes also as JsonPoiner instances (#60)jsonptr
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -594,6 +594,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'] @@ -608,6 +629,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 |