summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorJohan Forsberg <johan.forsberg@gmail.com>2014-01-11 21:40:29 +0100
committerJohan Forsberg <johan.forsberg@gmail.com>2014-01-11 21:40:29 +0100
commit7e459af293954675a5ac9852008666bfd95187ea (patch)
tree19f9d21932864b54df0f8cf404150de3c339efb1 /tests.py
parent48f9adb8991deb62ba4f327d5e96766c4d0d55e7 (diff)
downloadpython-json-patch-7e459af293954675a5ac9852008666bfd95187ea.tar.gz
allow moving array items into other items in same array
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 3fbffbb..c071ce2 100755
--- a/tests.py
+++ b/tests.py
@@ -88,6 +88,12 @@ class ApplyPatchTestCase(unittest.TestCase):
res = jsonpatch.apply_patch(obj, [{'op': 'move', 'from': '/foo/1', 'path': '/foo/3'}])
self.assertEqual(res, {'foo': ['all', 'cows', 'eat', 'grass']})
+ def test_move_array_item_into_other_item(self):
+ obj = [{"foo": []}, {"bar": []}]
+ patch = [{"op": "move", "from": "/0", "path": "/0/bar/0"}]
+ res = jsonpatch.apply_patch(obj, patch)
+ self.assertEqual(res, [{'bar': [{"foo": []}]}])
+
def test_copy_object_key(self):
obj = {'foo': {'bar': 'baz', 'waldo': 'fred'},
'qux': {'corge': 'grault'}}