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)
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)
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'))
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)
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)
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)
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)
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)
def test_error4(): with pytest.raises(errors.TestError): response = http.HttpResponse("HTTP1.1 OK\r\n")
def test_error7(): with pytest.raises(errors.TestError): response = http.HttpResponse( "HTTP/1.1 200 OK\r\nContent-Encoding: XYZ\r\n")
def test_error6(): response = http.HttpResponse("HTTP/1.1 200 OK\r\ntest: hello\r\n")
def test_error5(): with pytest.raises(errors.TestError): response = http.HttpResponse("HTTP/1.1 200 OK\r\ntest\r\n")
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'))