def test_base64_encoding(): resp = Response( status_code=200, headers={}, body={"message": "received GET"}, base64_encode=True, ) resp = resp.to_json() assert resp["body"] == b"eyJtZXNzYWdlIjogInJlY2VpdmVkIEdFVCJ9"
def post(self, foo_id): resp = Response( status_code=201, headers={}, body={ "message": "received the following data %s" % router.current_request.body }, ) return resp.to_json()
def test_response_obj(): resp = Response(status_code=200, headers={}, body={"message": "received GET"}) j = resp.to_json() assert resp.statusCode == 200 assert type(resp.statusCode) == int assert resp.headers == {} assert type(resp.headers) == dict assert resp.isBase64Encoded == False assert type(resp.isBase64Encoded) == bool assert resp.body["message"] == "received GET" assert type(resp.body) == dict # Test output of to_json() assert type(j["body"]) == str
def put(self, foo_id): resp = Response(status_code=200, headers={}, body={"message": "received PUT"}) return resp.to_json()
def get(self): resp = Response(status_code=200, headers={}, body={"message": "received GET"}) return resp.to_json()
def delete(self, **kwargs) -> dict: resp = Response(status_code=405, headers={}, body={"message": "Method not implemented"}) return resp.to_json()