File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -262,6 +262,22 @@ def test_add_nested(self):
262262 self .assertEqual (expected , res )
263263
264264
265+ class InvalidInputTests (unittest .TestCase ):
266+
267+ def test_missing_op (self ):
268+ # an "op" member is required
269+ src = {"foo" : "bar" }
270+ patch_obj = [ { "path" : "/child" , "value" : { "grandchild" : { } } } ]
271+ self .assertRaises (jsonpatch .JsonPatchException , jsonpatch .apply_patch , src , patch_obj )
272+
273+
274+ def test_invalid_op (self ):
275+ # "invalid" is not a valid operation
276+ src = {"foo" : "bar" }
277+ patch_obj = [ { "op" : "invalid" , "path" : "/child" , "value" : { "grandchild" : { } } } ]
278+ self .assertRaises (jsonpatch .JsonPatchException , jsonpatch .apply_patch , src , patch_obj )
279+
280+
265281modules = ['jsonpatch' ]
266282
267283
@@ -271,6 +287,7 @@ def get_suite():
271287 suite .addTest (unittest .makeSuite (ApplyPatchTestCase ))
272288 suite .addTest (unittest .makeSuite (EqualityTestCase ))
273289 suite .addTest (unittest .makeSuite (MakePatchTestCase ))
290+ suite .addTest (unittest .makeSuite (InvalidInputTests ))
274291 return suite
275292
276293
You can’t perform that action at this time.
0 commit comments