예제 #1
0
def test_http():
    response = []
    buffer = []

    def start_response(status, headers):
        response[:] = [status, headers]
        return buffer.append

    http = HTTP(200, 'Hello World',
                headers={'X-Test': 'Hello Header'},
                cookies={'cookie_test': 'hello cookie'})

    assert http.encoded_body == b'Hello World'
    assert http.status_code == 200
    assert http.headers == [
        (b'X-Test', b'Hello Header'), (b'Set-Cookie', b'e')]
예제 #2
0
def test_http_default():
    http = HTTP(200)

    assert http.encoded_body is b''
    assert http.status_code == 200
    assert http.headers == [(b'Content-Type', b'text/plain')]