From fb04fcc4df0e060586f6401b61af703d60bb6b65 Mon Sep 17 00:00:00 2001 From: Artyom Nikitin Date: Sun, 15 Nov 2020 17:27:33 +0300 Subject: test: add more tests --- tests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests.py b/tests.py index 0402a03..ec4758d 100755 --- a/tests.py +++ b/tests.py @@ -676,6 +676,28 @@ class CustomJsonPointerTests(unittest.TestCase): class CustomJsonPointer(jsonpointer.JsonPointer): pass + def test_json_patch_from_string(self): + patch = '[{"op": "add", "path": "/baz", "value": "qux"}]' + res = jsonpatch.JsonPatch.from_string( + patch, pointer_cls=self.CustomJsonPointer, + ) + self.assertEqual(res.pointer_cls, self.CustomJsonPointer) + + def test_json_patch_from_object(self): + patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}], + res = jsonpatch.JsonPatch( + patch, pointer_cls=self.CustomJsonPointer, + ) + self.assertEqual(res.pointer_cls, self.CustomJsonPointer) + + def test_json_patch_from_diff(self): + old = {'foo': 'bar'} + new = {'foo': 'baz'} + res = jsonpatch.JsonPatch.from_diff( + old, new, pointer_cls=self.CustomJsonPointer, + ) + self.assertEqual(res.pointer_cls, self.CustomJsonPointer) + def test_apply_patch_from_string(self): obj = {'foo': 'bar'} patch = '[{"op": "add", "path": "/baz", "value": "qux"}]' -- cgit v1.2.1