Skip to content

Commit

Permalink
tests: moar
Browse files Browse the repository at this point in the history
  • Loading branch information
Artyom Nikitin committed Nov 17, 2020
1 parent c9613e3 commit 50fb942
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests.py
Expand Up @@ -738,6 +738,44 @@ def test_make_patch(self):
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'},
Expand Down

0 comments on commit 50fb942

Please sign in to comment.