diff options
author | Artyom Nikitin <a.nikitin@edadeal.ru> | 2020-11-17 11:02:15 +0300 |
---|---|---|
committer | Artyom Nikitin <a.nikitin@edadeal.ru> | 2020-11-17 11:02:15 +0300 |
commit | 0994bfe2ce199d6edccb4ab97fc10e3c26683348 (patch) | |
tree | 82502f0fafd38b9f24852d3cd2eccbacc9c9dc65 | |
parent | c37b40ffec5674bf76bbb2197917e528e74b4552 (diff) | |
download | python-json-patch-0994bfe2ce199d6edccb4ab97fc10e3c26683348.tar.gz |
test: add toy jsonpointer example
-rwxr-xr-x | tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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'] |