forked from orbit-oss/flask
Merge pull request #439 from aisipos/jsonexceptions
Add new exceptions module, to implement JSONHttpException and JSONBadRequest.
This commit is contained in:
commit
f43003967e
4 changed files with 78 additions and 4 deletions
|
|
@ -40,6 +40,18 @@ class JSONTestCase(FlaskTestCase):
|
|||
rv = c.post('/json', data='malformed', content_type='application/json')
|
||||
self.assert_equal(rv.status_code, 400)
|
||||
|
||||
def test_json_bad_requests_content_type(self):
|
||||
app = flask.Flask(__name__)
|
||||
@app.route('/json', methods=['POST'])
|
||||
def return_json():
|
||||
return unicode(flask.request.json)
|
||||
c = app.test_client()
|
||||
rv = c.post('/json', data='malformed', content_type='application/json')
|
||||
self.assert_equal(rv.status_code, 400)
|
||||
self.assert_equal(rv.mimetype, 'application/json')
|
||||
self.assert_('description' in flask.json.loads(rv.data))
|
||||
self.assert_('<p>' not in flask.json.loads(rv.data)['description'])
|
||||
|
||||
def test_json_body_encoding(self):
|
||||
app = flask.Flask(__name__)
|
||||
app.testing = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue