def test_post(self): res = self.fetch('/echo', method='POST', headers={'Content-Type': 'application/json'}, body=json.dumps({'name': 'Steve'})) json_body = parse_json(res.body) assert json_body['name'] == 'Steve' res = self.fetch('/echo', method='POST', headers={'Content-Type': 'application/json'}, body=json.dumps({})) json_body = parse_json(res.body) assert json_body['name'] is None
def test_required_field_provided(self): res = self.fetch( '/echo', method='POST', headers={'Content-Type': 'application/json'}, body=json.dumps({'name': 'johnny'}), ) json_body = parse_json(res.body) assert json_body['name'] == 'johnny'
def test_get_with_no_json_body(self): res = self.fetch('/echo', method='GET', headers={'Content-Type': 'application/json'}) json_body = parse_json(res.body) assert json_body['name'] is None