summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2013-07-12 19:43:10 +0200
committerStefan Kögl <stefan@skoegl.net>2013-07-12 19:43:10 +0200
commit35721f962ee05e86482a348c8530138e699542ee (patch)
treefc5c5b99a9cc534a011c2f60e6db3c347d05ed91
parentb369c2372b5cd15e55933919d306cbae93da8c27 (diff)
downloadpython-json-patch-35721f962ee05e86482a348c8530138e699542ee.tar.gz
add test for replaceing whole document by "add"
-rwxr-xr-xtests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 7049055..9b58cfe 100755
--- a/tests.py
+++ b/tests.py
@@ -63,6 +63,12 @@ class ApplyPatchTestCase(unittest.TestCase):
res = jsonpatch.apply_patch(obj, [{'op': 'replace', 'path': '', 'value': {'baz': 'qux'}}])
self.assertTrue(res['baz'], 'qux')
+ def test_add_replace_whole_document(self):
+ obj = {'foo': 'bar'}
+ new_obj = {'baz': 'qux'}
+ res = jsonpatch.apply_patch(obj, [{'op': 'add', 'path': '', 'value': new_obj}])
+ self.assertTrue(res, new_obj)
+
def test_replace_array_item(self):
obj = {'foo': ['bar', 'qux', 'baz']}
res = jsonpatch.apply_patch(obj, [{'op': 'replace', 'path': '/foo/1',