def test_is_json(): app = Shake(__file__) data = {'foo': 'bar', 'num': 3} @app.route('/') def index(request): return str(request.json) c = app.test_client() resp = c.post('/', content_type='application/json', data=json.dumps(data)) assert eval(resp.data) == data resp = c.post('/', data=json.dumps(data)) assert resp.data == 'None'
def test_is_json(): data = {'foo': 'bar', 'num': 3} def index(request): return str(request.json) urls = [ Rule('/', index), ] app = Shake(urls) c = app.test_client() resp = c.post('/', content_type='application/json', data=json.dumps(data)) assert eval(resp.data) == data resp = c.post('/', data=json.dumps(data)) assert resp.data == 'None'