Esempio n. 1
0
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"
Esempio n. 2
0
        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()
Esempio n. 3
0
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
Esempio n. 4
0
        def put(self, foo_id):
            resp = Response(status_code=200,
                            headers={},
                            body={"message": "received PUT"})

            return resp.to_json()
Esempio n. 5
0
        def get(self):
            resp = Response(status_code=200,
                            headers={},
                            body={"message": "received GET"})

            return resp.to_json()
Esempio n. 6
0
 def delete(self, **kwargs) -> dict:
     resp = Response(status_code=405,
                     headers={},
                     body={"message": "Method not implemented"})
     return resp.to_json()