Skip to content

Commit 0994bfe

Browse files
author
Artyom Nikitin
committed
test: add toy jsonpointer example
1 parent c37b40f commit 0994bfe

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,17 @@ def test_operations(self):
748748
self.assertIsInstance(op.pointer, self.CustomJsonPointer)
749749
self.assertEqual(op.pointer_cls, self.CustomJsonPointer)
750750

751+
class PrefixJsonPointer(jsonpointer.JsonPointer):
752+
def __init__(self, pointer):
753+
super().__init__('/foo/bar' + pointer)
754+
755+
def test_json_patch_wtih_prefix_pointer(self):
756+
res = jsonpatch.apply_patch(
757+
{'foo': {'bar': {}}}, [{'op': 'add', 'path': '/baz', 'value': 'qux'}],
758+
pointer_cls=self.PrefixJsonPointer,
759+
)
760+
self.assertEqual(res, {'foo': {'bar': {'baz': 'qux'}}})
761+
751762

752763
if __name__ == '__main__':
753764
modules = ['jsonpatch']

0 commit comments

Comments
 (0)