@@ -75,6 +75,12 @@ def test_replace_array_item(self):
75
75
'value' : 'boo' }])
76
76
self .assertEqual (res ['foo' ], ['bar' , 'boo' , 'baz' ])
77
77
78
+ def test_move_object_keyerror (self ):
79
+ obj = {'foo' : {'bar' : 'baz' },
80
+ 'qux' : {'corge' : 'grault' }}
81
+ patch_obj = [ {'op' : 'move' , 'from' : '/foo/non-existent' , 'path' : '/qux/thud' } ]
82
+ self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , obj , patch_obj )
83
+
78
84
def test_move_object_key (self ):
79
85
obj = {'foo' : {'bar' : 'baz' , 'waldo' : 'fred' },
80
86
'qux' : {'corge' : 'grault' }}
@@ -94,6 +100,12 @@ def test_move_array_item_into_other_item(self):
94
100
res = jsonpatch .apply_patch (obj , patch )
95
101
self .assertEqual (res , [{'bar' : [{"foo" : []}]}])
96
102
103
+ def test_copy_object_keyerror (self ):
104
+ obj = {'foo' : {'bar' : 'baz' },
105
+ 'qux' : {'corge' : 'grault' }}
106
+ patch_obj = [{'op' : 'copy' , 'from' : '/foo/non-existent' , 'path' : '/qux/thud' }]
107
+ self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , obj , patch_obj )
108
+
97
109
def test_copy_object_key (self ):
98
110
obj = {'foo' : {'bar' : 'baz' , 'waldo' : 'fred' },
99
111
'qux' : {'corge' : 'grault' }}
@@ -314,6 +326,11 @@ def test_remove_keyerror(self):
314
326
patch_obj = [ { "op" : "remove" , "path" : "/foo/b" } ]
315
327
self .assertRaises (jsonpointer .JsonPointerException , jsonpatch .apply_patch , src , patch_obj )
316
328
329
+ def test_remove_keyerror_dict (self ):
330
+ src = {'foo' : {'bar' : 'barz' }}
331
+ patch_obj = [ { "op" : "remove" , "path" : "/foo/non-existent" } ]
332
+ self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , src , patch_obj )
333
+
317
334
def test_insert_oob (self ):
318
335
src = {"foo" : [1 , 2 ]}
319
336
patch_obj = [ { "op" : "add" , "path" : "/foo/10" , "value" : 1 } ]
0 commit comments