summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Nikitin <a.nikitin@edadeal.ru>2020-11-17 11:02:15 +0300
committerArtyom Nikitin <a.nikitin@edadeal.ru>2020-11-17 11:02:15 +0300
commit0994bfe2ce199d6edccb4ab97fc10e3c26683348 (patch)
tree82502f0fafd38b9f24852d3cd2eccbacc9c9dc65
parentc37b40ffec5674bf76bbb2197917e528e74b4552 (diff)
downloadpython-json-patch-0994bfe2ce199d6edccb4ab97fc10e3c26683348.tar.gz
test: add toy jsonpointer example
-rwxr-xr-xtests.py11
1 files changed, 11 insertions, 0 deletions
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']