summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Nikitin <a.nikitin@edadeal.ru>2020-11-15 17:27:33 +0300
committerArtyom Nikitin <a.nikitin@edadeal.ru>2020-11-15 17:27:33 +0300
commitfb04fcc4df0e060586f6401b61af703d60bb6b65 (patch)
tree5b1fec6fb8e238a3f4ea282a6bc7084c720864b9
parent124eb76c09136aef56618e7347230f981edd51c3 (diff)
downloadpython-json-patch-fb04fcc4df0e060586f6401b61af703d60bb6b65.tar.gz
test: add more tests
-rwxr-xr-xtests.py22
1 files changed, 22 insertions, 0 deletions
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"}]'