diff options
author | Kirill Goldshtein <goldshtein.kirill@gmail.com> | 2016-05-04 09:53:57 +0300 |
---|---|---|
committer | Kirill Goldshtein <goldshtein.kirill@gmail.com> | 2016-05-04 09:53:57 +0300 |
commit | 72a90e3ff1e75c6628106509568de9e22ca2b259 (patch) | |
tree | 1c2ec577483b9775f11028f11e1fc79d3178632c /tests.py | |
parent | 5cc9bee572f6207166122ac2ba9cecde0598930a (diff) | |
download | python-json-patch-72a90e3ff1e75c6628106509568de9e22ca2b259.tar.gz |
Fix KeyError in add/remove optimization
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -317,6 +317,15 @@ class MakePatchTestCase(unittest.TestCase): res = jsonpatch.apply_patch(src, patch) self.assertEqual(res, dst) + def test_use_replace_instead_of_remove_add_nested(self): + src = {'foo': [{'bar': 1, 'baz': 2}, {'bar': 2, 'baz': 3}]} + dst = {'foo': [{'bar': 1}, {'bar': 2, 'baz': 3}]} + patch = list(jsonpatch.make_patch(src, dst)) + self.assertEqual(len(patch), 1) + self.assertEqual(patch[0]['op'], 'replace') + res = jsonpatch.apply_patch(src, patch) + self.assertEqual(res, dst) + def test_use_move_instead_of_remove_add(self): src = {'foo': [4, 1, 2, 3]} dst = {'foo': [1, 2, 3, 4]} |