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']
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
def test_consume_byte_by_byte(parser, header, parsed, header_dict): for c in header: parser.consume(c.encode())
def test_good_header_pieces(parser, req_pieces, expected_header): for piece in req_pieces: parser.consume(piece) assert parser.headers == expected_header
def test_good_header_all(parser, mock_responder, header, header_dict): parser.consume(header) assert parser.headers == header_dict
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)
def test_bad_request(parser, req_str, err): with pytest.raises(err): parser.consume(req_str)
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)
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)