summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorselurvedu <selurvedu@users.noreply.github.com>2015-08-14 15:45:03 +0000
committerselurvedu <selurvedu@users.noreply.github.com>2016-04-08 04:38:18 +0000
commit282bebae977021b6f1d19fad0c967eb625af7331 (patch)
treefbf19978209e2597531fd76ba8de2c19ff116525
parent66c4fa4ba18c5e8eeca09280eb0ea43c9684465d (diff)
downloadpython-json-patch-282bebae977021b6f1d19fad0c967eb625af7331.tar.gz
Extend tests that check list patching
-rwxr-xr-xtests.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests.py b/tests.py
index 5b0d9e9..bb9e296 100755
--- a/tests.py
+++ b/tests.py
@@ -327,13 +327,17 @@ class MakePatchTestCase(unittest.TestCase):
self.assertEqual(res, dst)
def test_use_move_instead_of_add_remove(self):
- src = {'foo': [1, 2, 3]}
- dst = {'foo': [3, 1, 2]}
- patch = list(jsonpatch.make_patch(src, dst))
- self.assertEqual(len(patch), 1)
- self.assertEqual(patch[0]['op'], 'move')
- res = jsonpatch.apply_patch(src, patch)
- self.assertEqual(res, dst)
+ def fn(_src, _dst):
+ patch = list(jsonpatch.make_patch(_src, _dst))
+ self.assertEqual(len(patch), 1)
+ self.assertEqual(patch[0]['op'], 'move')
+ res = jsonpatch.apply_patch(_src, patch)
+ self.assertEqual(res, _dst)
+
+ fn({'foo': [1, 2, 3]}, {'foo': [3, 1, 2]})
+ fn({'foo': [1, 2, 3]}, {'foo': [3, 2, 1]})
+ fn([1, 2, 3], [3, 1, 2])
+ fn([1, 2, 3], [3, 2, 1])
def test_escape(self):
src = {"x/y": 1}