diff options
author | Kostya <suffering.death@gmail.com> | 2017-04-27 17:05:55 +0300 |
---|---|---|
committer | Kostya <suffering.death@gmail.com> | 2017-04-27 17:05:55 +0300 |
commit | e18a131be0aba0a065a5709f420ef88ec1a3fd83 (patch) | |
tree | 1e2d12c715dae5bd61cc2e89a7ff82f3984881cf /tests.py | |
parent | 05d9aceda8d0269c27d869f13d8ba0c7ca88104e (diff) | |
download | python-json-patch-e18a131be0aba0a065a5709f420ef88ec1a3fd83.tar.gz |
don't apply patch optimization when it's incorrect
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -267,7 +267,6 @@ class EqualityTestCase(unittest.TestCase): self.assertEqual(json.dumps(patch_obj), patch.to_string()) - class MakePatchTestCase(unittest.TestCase): def test_apply_patch_to_copy(self): @@ -336,7 +335,6 @@ class MakePatchTestCase(unittest.TestCase): res = jsonpatch.apply_patch(src, patch) self.assertEqual(res, dst) - def test_escape(self): src = {"x/y": 1} dst = {"x/y": 2} @@ -368,6 +366,17 @@ class MakePatchTestCase(unittest.TestCase): dest = [7, 2, 1, 0, 9, 4, 3, 6, 5, 8] patch = jsonpatch.make_patch(src, dest) + def test_json_patch(self): + old = { + 'queue': {'teams_out': [{'id': 3, 'reason': 'If tied'}, {'id': 5, 'reason': 'If tied'}]}, + } + new = { + 'queue': {'teams_out': [{'id': 5, 'reason': 'If lose'}]} + } + patch = jsonpatch.make_patch(old, new) + new_from_patch = jsonpatch.apply_patch(old, patch) + self.assertEqual(new, new_from_patch) + class OptimizationTests(unittest.TestCase): def test_use_replace_instead_of_remove_add(self): |