예제 #1
0
 def _assert_bad_request(self, data, schema, as_json=False):
     if as_json:
         data = json.dumps(data)
     with self.app.test_request_context(method="POST", data=data, content_type="application/json" if as_json else None):
         with self.assertRaises(HTTPException) as caught:
             weber_utils.get_request_input(schema)
         self.assertEquals(caught.exception.code, httplib.BAD_REQUEST)
예제 #2
0
 def _assert_bad_request(self, data, schema, as_json=False):
     if as_json:
         data = json.dumps(data)
     with self.app.test_request_context(
             method="POST",
             data=data,
             content_type="application/json" if as_json else None):
         with self.assertRaises(HTTPException) as caught:
             weber_utils.get_request_input(schema)
         self.assertEquals(caught.exception.code, httplib.BAD_REQUEST)
예제 #3
0
 def test_request_input_json(self):
     data = {"a": 2, "b": "c"}
     with self.app.test_request_context(method="POST",
                                        data=json.dumps(data),
                                        content_type="application/json"):
         self.assertEquals(
             weber_utils.get_request_input({
                 "a": int,
                 "b": string_types
             }), data)
예제 #4
0
 def test_request_input_form(self):
     data = {"a": "2", "b": "c"}
     with self.app.test_request_context(method="POST", data=data):
         self.assertEquals(
             weber_utils.get_request_input({
                 "a": int,
                 "b": string_types
             }), {
                 "a": 2,
                 "b": "c"
             })
예제 #5
0
 def test_request_input_form(self):
     data = {"a": "2", "b": "c"}
     with self.app.test_request_context(method="POST", data=data):
         self.assertEquals(weber_utils.get_request_input({"a": int, "b": string_types}), {"a": 2, "b": "c"})
예제 #6
0
 def test_request_input_json(self):
     data = {"a": 2, "b": "c"}
     with self.app.test_request_context(method="POST", data=json.dumps(data), content_type="application/json"):
         self.assertEquals(weber_utils.get_request_input({"a": int, "b": string_types}), data)