Esempio n. 1
0
def test_good_request(parser, fullreq, expected):
    body = parser.consume(fullreq)
    assert parser.EOL_TOKEN == expected['EOL']
    assert parser.HTTP_VERSION == expected['version']
    assert parser.path == expected['path']
    assert parser.headers == expected['headers']
    assert body == expected['body']
Esempio n. 2
0
def test_good_request(parser, fullreq, expected):
    body = parser.consume(fullreq)
    assert parser.EOL_TOKEN == expected['EOL']
    assert parser.HTTP_VERSION == expected['version']
    assert parser.path == expected['path']
    assert parser.headers == expected['headers']
    assert body == expected['body']
Esempio n. 3
0
def test_aquire_newline_byte_by_byte(line, value, parser):
    assert parser.EOL_TOKEN is None
    for c in line:
        parser.consume(c.encode())
    assert parser.EOL_TOKEN == value
Esempio n. 4
0
def test_consume_byte_by_byte(parser, header, parsed, header_dict):
    for c in header:
        parser.consume(c.encode())
Esempio n. 5
0
def test_good_header_pieces(parser, req_pieces, expected_header):

    for piece in req_pieces:
        parser.consume(piece)

    assert parser.headers == expected_header
Esempio n. 6
0
def test_good_header_all(parser, mock_responder, header, header_dict):
    parser.consume(header)
    assert parser.headers == header_dict
Esempio n. 7
0
def test_request_too_long(parser):
    req_str = b'GET /path HTTP/1.1\n\n' + b'X' * (growler.http.parser.MAX_REQUEST_LENGTH + 4)
    with pytest.raises(HTTPErrorBadRequest):
        parser.consume(req_str)
Esempio n. 8
0
def test_bad_request(parser, req_str, err):
    with pytest.raises(err):
        parser.consume(req_str)
Esempio n. 9
0
def notest_consume_request_line(parser, data, method, parsed, version):
    parser.consume(data)
    parser.parent.set_request_line.assert_called_with(method,
                                                      ParseResult(*parsed),
                                                      version)
Esempio n. 10
0
def test_aquire_newline_byte_by_byte(line, value, parser):
    assert parser.EOL_TOKEN is None
    for c in line:
        parser.consume(c.encode())
    assert parser.EOL_TOKEN == value
Esempio n. 11
0
def test_consume_byte_by_byte(parser, header, parsed, header_dict):
    for c in header:
        parser.consume(c.encode())
Esempio n. 12
0
def test_good_header_pieces(parser, req_pieces, expected_header):

    for piece in req_pieces:
        parser.consume(piece)

    assert parser.headers == expected_header
Esempio n. 13
0
def test_good_header_all(parser, mock_responder, header, header_dict):
    parser.consume(header)
    assert parser.headers == header_dict
Esempio n. 14
0
def test_request_too_long(parser):
    req_str = b'GET /path HTTP/1.1\n\n' + b'X' * (
        growler.http.parser.MAX_REQUEST_LENGTH + 4)
    with pytest.raises(HTTPErrorBadRequest):
        parser.consume(req_str)
Esempio n. 15
0
def test_bad_request(parser, req_str, err):
    with pytest.raises(err):
        parser.consume(req_str)
Esempio n. 16
0
def notest_consume_request_line(parser, data, method, parsed, version):
    parser.consume(data)
    parser.parent.set_request_line.assert_called_with(method,
                                                      ParseResult(*parsed),
                                                      version)