summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorKostya <suffering.death@gmail.com>2017-04-27 17:05:55 +0300
committerKostya <suffering.death@gmail.com>2017-04-27 17:05:55 +0300
commite18a131be0aba0a065a5709f420ef88ec1a3fd83 (patch)
tree1e2d12c715dae5bd61cc2e89a7ff82f3984881cf /tests.py
parent05d9aceda8d0269c27d869f13d8ba0c7ca88104e (diff)
downloadpython-json-patch-e18a131be0aba0a065a5709f420ef88ec1a3fd83.tar.gz
don't apply patch optimization when it's incorrect
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests.py b/tests.py
index 4b7d505..51d9517 100755
--- a/tests.py
+++ b/tests.py
@@ -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):