summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2013-07-11 22:09:17 +0200
committerStefan Kögl <stefan@skoegl.net>2013-07-11 22:09:17 +0200
commit61b7412cd1b7e18d044975e92b09c365460ffd4e (patch)
tree27278274d843418520e7fb77332c608d131be98c
parentc84a5567368f4712950909b1e6a135bc0e91e097 (diff)
downloadpython-json-patch-61b7412cd1b7e18d044975e92b09c365460ffd4e.tar.gz
test some invalid inputs
-rwxr-xr-xtests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index bdd6fcf..8e1b22e 100755
--- a/tests.py
+++ b/tests.py
@@ -262,6 +262,22 @@ class MakePatchTestCase(unittest.TestCase):
self.assertEqual(expected, res)
+class InvalidInputTests(unittest.TestCase):
+
+ def test_missing_op(self):
+ # an "op" member is required
+ src = {"foo": "bar"}
+ patch_obj = [ { "path": "/child", "value": { "grandchild": { } } } ]
+ self.assertRaises(jsonpatch.JsonPatchException, jsonpatch.apply_patch, src, patch_obj)
+
+
+ def test_invalid_op(self):
+ # "invalid" is not a valid operation
+ src = {"foo": "bar"}
+ patch_obj = [ { "op": "invalid", "path": "/child", "value": { "grandchild": { } } } ]
+ self.assertRaises(jsonpatch.JsonPatchException, jsonpatch.apply_patch, src, patch_obj)
+
+
modules = ['jsonpatch']
@@ -271,6 +287,7 @@ def get_suite():
suite.addTest(unittest.makeSuite(ApplyPatchTestCase))
suite.addTest(unittest.makeSuite(EqualityTestCase))
suite.addTest(unittest.makeSuite(MakePatchTestCase))
+ suite.addTest(unittest.makeSuite(InvalidInputTests))
return suite