Esempio n. 1
0
def test_response_cookie():
    response = Response()
    response.headers.cookie[str('foo')] = str('bar')

    def start_response(status, headers):
        assert headers[0][0] == str('Set-Cookie')
        assert headers[0][1].startswith(str('foo=bar'))

    response.to_wsgi({}, start_response, 'utf8')
Esempio n. 2
0
def test_response_headers_are_str():
    response = Response()
    response.headers[b'Location'] = b'somewhere'

    def start_response(status, headers):
        assert isinstance(headers[0][0], str)
        assert isinstance(headers[0][1], str)

    response.to_wsgi({}, start_response, 'utf8')
Esempio n. 3
0
def test_response_body_as_bytestring_results_in_an_iterable():
    response = Response(body=b"Greetings, program!")

    def start_response(status, headers):
        pass

    expected = [b"Greetings, program!"]
    actual = list(response.to_wsgi({}, start_response, 'utf8').body)
    assert actual == expected
Esempio n. 4
0
def test_response_body_as_iterable_comes_through_untouched():
    response = Response(body=[b"Greetings, ", b"program!"])

    def start_response(status, headers):
        pass

    expected = [b"Greetings, ", b"program!"]
    actual = list(response.to_wsgi({}, start_response, 'utf8').body)
    assert actual == expected
Esempio n. 5
0
def test_response_to_wsgi():
    response = Response(body=b"Greetings, program!")

    def start_response(status, headers):
        pass

    expected = [b"Greetings, program!"]
    actual = list(response.to_wsgi({}, start_response, 'utf8').body)
    assert actual == expected