def test_parser_fail(): """Test non-success response from proxy.""" response = [b'HTTP/1.1 407 auth required\r\n', b'foo: bar\r\n\r\n'] proxy_parser = proxy.ProxyParser() with pytest.raises(proxy.ProxyFail): for line in response: for response in proxy_parser.feed(line): break
def test_parser(): response = [ b'HTTP/1.1 200 Connection established\r\n', b'foo: bar\r\n', b'\r\n', ] proxy_parser = proxy.ProxyParser() for line in response: for response in proxy_parser.feed(line): break assert response.status == 'Connection established' assert response.status_code == 200 assert response.headers['foo'] == 'bar'
def test_parser_fail_nodata(): """Test no response from proxy.""" proxy_parser = proxy.ProxyParser() with pytest.raises(proxy.ProxyFail): for response in proxy_parser.feed(b''): break