Esempio n. 1
0
def test_invalid_brotli():
    """Invalid brotli content"""
    http_ua = http.HttpUA()
    with pytest.raises(errors.TestError):
        http.HttpResponse('HTTP1.1 200 OK\r\n'
                          'Content-Encoding: br\r\n\r\ninvalid data',
                          http_ua)
Esempio n. 2
0
def test_invalid_deflate():
    """Invalid deflate content"""
    http_ua = http.HttpUA()
    with pytest.raises(errors.TestError):
        http.HttpResponse(
            "HTTP1.1 200 OK\r\n"
            "Content-Encoding: deflate\r\n\r\ninvalid data", http_ua)
Esempio n. 3
0
def test_response_failure():
    runner = testrunner.TestRunner()
    http_ua = http.HttpUA()
    with pytest.raises(AssertionError):
        runner.test_response(
            http.HttpResponse('HTTP/1.1 200 OK\r\n\r\ncat', http_ua),
            re.compile('dog'))
Esempio n. 4
0
def test_error4():
    """Wrong number of elements returned in response line"""
    with pytest.raises(errors.TestError):
        http_ua = http.HttpUA()
        response = http.HttpResponse("HTTP1.1 OK\r\n", http_ua)
Esempio n. 5
0
def test_error3():
    """Invalid status returned in response line"""
    http_ua = http.HttpUA()
    with pytest.raises(errors.TestError):
        response = http.HttpResponse("HTTP1.1 test OK\r\n", http_ua)
Esempio n. 6
0
def test_error7():
    """Invalid content-type should fail"""
    http_ua = http.HttpUA()
    with pytest.raises(errors.TestError):
        response = http.HttpResponse(
            "HTTP/1.1 200 OK\r\nContent-Encoding: XYZ\r\n", http_ua)
Esempio n. 7
0
def test_error6():
    """Valid HTTP response should process fine"""
    http_ua = http.HttpUA()
    response = http.HttpResponse("HTTP/1.1 200 OK\r\ntest: hello\r\n", http_ua)
Esempio n. 8
0
def test_error5():
    """Invalid Header should cause error"""
    http_ua = http.HttpUA()
    with pytest.raises(errors.TestError):
        response = http.HttpResponse("HTTP/1.1 200 OK\r\ntest\r\n", http_ua)
Esempio n. 9
0
def test_error4():
    with pytest.raises(errors.TestError):
        response = http.HttpResponse("HTTP1.1 OK\r\n")
Esempio n. 10
0
def test_error7():
    with pytest.raises(errors.TestError):
        response = http.HttpResponse(
            "HTTP/1.1 200 OK\r\nContent-Encoding: XYZ\r\n")
Esempio n. 11
0
def test_error6():
    response = http.HttpResponse("HTTP/1.1 200 OK\r\ntest: hello\r\n")
Esempio n. 12
0
def test_error5():
    with pytest.raises(errors.TestError):
        response = http.HttpResponse("HTTP/1.1 200 OK\r\ntest\r\n")
Esempio n. 13
0
def test_response_success():
    runner = testrunner.TestRunner()
    http_ua = http.HttpUA()
    runner.test_response(
        http.HttpResponse('HTTP/1.1 200 OK\r\n\r\ncat', http_ua),
        re.compile('cat'))