diff options
author | Artyom Nikitin <a.nikitin@edadeal.ru> | 2020-11-15 17:27:33 +0300 |
---|---|---|
committer | Artyom Nikitin <a.nikitin@edadeal.ru> | 2020-11-15 17:27:33 +0300 |
commit | fb04fcc4df0e060586f6401b61af703d60bb6b65 (patch) | |
tree | 5b1fec6fb8e238a3f4ea282a6bc7084c720864b9 /tests.py | |
parent | 124eb76c09136aef56618e7347230f981edd51c3 (diff) | |
download | python-json-patch-fb04fcc4df0e060586f6401b61af703d60bb6b65.tar.gz |
test: add more tests
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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"}]' |