From 0994bfe2ce199d6edccb4ab97fc10e3c26683348 Mon Sep 17 00:00:00 2001 From: Artyom Nikitin Date: Tue, 17 Nov 2020 11:02:15 +0300 Subject: test: add toy jsonpointer example --- tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests.py b/tests.py index 941c685..25c9e4f 100755 --- a/tests.py +++ b/tests.py @@ -748,6 +748,17 @@ class CustomJsonPointerTests(unittest.TestCase): self.assertIsInstance(op.pointer, self.CustomJsonPointer) self.assertEqual(op.pointer_cls, self.CustomJsonPointer) + class PrefixJsonPointer(jsonpointer.JsonPointer): + def __init__(self, pointer): + super().__init__('/foo/bar' + pointer) + + def test_json_patch_wtih_prefix_pointer(self): + res = jsonpatch.apply_patch( + {'foo': {'bar': {}}}, [{'op': 'add', 'path': '/baz', 'value': 'qux'}], + pointer_cls=self.PrefixJsonPointer, + ) + self.assertEqual(res, {'foo': {'bar': {'baz': 'qux'}}}) + if __name__ == '__main__': modules = ['jsonpatch'] -- cgit v1.2.1