Skip to content

Commit fb04fcc

Browse files
author
Artyom Nikitin
committed
test: add more tests
1 parent 124eb76 commit fb04fcc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,28 @@ class CustomJsonPointerTests(unittest.TestCase):
676676
class CustomJsonPointer(jsonpointer.JsonPointer):
677677
pass
678678

679+
def test_json_patch_from_string(self):
680+
patch = '[{"op": "add", "path": "/baz", "value": "qux"}]'
681+
res = jsonpatch.JsonPatch.from_string(
682+
patch, pointer_cls=self.CustomJsonPointer,
683+
)
684+
self.assertEqual(res.pointer_cls, self.CustomJsonPointer)
685+
686+
def test_json_patch_from_object(self):
687+
patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}],
688+
res = jsonpatch.JsonPatch(
689+
patch, pointer_cls=self.CustomJsonPointer,
690+
)
691+
self.assertEqual(res.pointer_cls, self.CustomJsonPointer)
692+
693+
def test_json_patch_from_diff(self):
694+
old = {'foo': 'bar'}
695+
new = {'foo': 'baz'}
696+
res = jsonpatch.JsonPatch.from_diff(
697+
old, new, pointer_cls=self.CustomJsonPointer,
698+
)
699+
self.assertEqual(res.pointer_cls, self.CustomJsonPointer)
700+
679701
def test_apply_patch_from_string(self):
680702
obj = {'foo': 'bar'}
681703
patch = '[{"op": "add", "path": "/baz", "value": "qux"}]'

0 commit comments

Comments
 (0)