diff options
author | Artyom Nikitin <a.nikitin@edadeal.ru> | 2020-11-17 20:54:36 +0300 |
---|---|---|
committer | Artyom Nikitin <a.nikitin@edadeal.ru> | 2020-11-17 20:54:36 +0300 |
commit | 50fb942e3500d84950ec9309f886f1952bd2fa25 (patch) | |
tree | ac0cc5d031fb6fc8b70cd14f72d9335b8afba0d2 | |
parent | c9613e303531ce4a016b3a696992743e62e12258 (diff) | |
download | python-json-patch-50fb942e3500d84950ec9309f886f1952bd2fa25.tar.gz |
tests: moar
-rwxr-xr-x | tests.py | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -738,6 +738,44 @@ class CustomJsonPointerTests(unittest.TestCase): self.assertEqual(op.pointer_cls, CustomJsonPointer) def test_operations(self): + operations =[ + ( + jsonpatch.AddOperation, { + 'op': 'add', 'path': '/foo', 'value': [1, 2, 3] + } + ), + ( + jsonpatch.MoveOperation, { + 'op': 'move', 'path': '/baz', 'from': '/foo' + }, + ), + ( + jsonpatch.RemoveOperation, { + 'op': 'remove', 'path': '/baz/1' + }, + ), + ( + jsonpatch.TestOperation, { + 'op': 'test', 'path': '/baz', 'value': [1, 3] + }, + ), + ( + jsonpatch.ReplaceOperation, { + 'op': 'replace', 'path': '/baz/0', 'value': 42 + }, + ), + ( + jsonpatch.RemoveOperation, { + 'op': 'remove', 'path': '/baz/1' + }, + ) + ] + for cls, patch in operations: + operation = cls(patch, pointer_cls=CustomJsonPointer) + self.assertEqual(operation.pointer_cls, CustomJsonPointer) + self.assertIsInstance(operation.pointer, CustomJsonPointer) + + def test_operations_from_patch(self): patch = jsonpatch.JsonPatch([ {'op': 'add', 'path': '/foo', 'value': [1, 2, 3]}, {'op': 'move', 'path': '/baz', 'from': '/foo'}, |