summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Nikitin <a.nikitin@edadeal.ru>2020-11-17 20:54:36 +0300
committerArtyom Nikitin <a.nikitin@edadeal.ru>2020-11-17 20:54:36 +0300
commit50fb942e3500d84950ec9309f886f1952bd2fa25 (patch)
treeac0cc5d031fb6fc8b70cd14f72d9335b8afba0d2
parentc9613e303531ce4a016b3a696992743e62e12258 (diff)
downloadpython-json-patch-50fb942e3500d84950ec9309f886f1952bd2fa25.tar.gz
tests: moar
-rwxr-xr-xtests.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index c676121..7df2c2b 100755
--- a/tests.py
+++ b/tests.py
@@ -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'},