def test_forbidden_error1(): s = HttpServer() with pytest.raises(ForbiddenError): body, content_type = s._retrieve_resource(b"../../etc/password/")
def test_retrieve_resources_2(): s = HttpServer() with pytest.raises(ResourceNotFound): s._retrieve_resource(b"afilethatdoesntexist.123")
def test_retrieve_resources_3(): s = HttpServer() body, content_type = s._retrieve_resource(b"") assert content_type == b"text/html"
def test_retrieve_resource_1(): test_string = u"Here is text with some unicode in it: ÄÄÄÄÄÄÄÄÄÄ" s = HttpServer() body, content_type = s._retrieve_resource(b"test.html") assert content_type == b"text/html" assert body.decode('utf-8') == test_string
def test_gen_response_1(): s = HttpServer() assert s._gen_response(301) == 'HTTP/1.1 301 Moved Permanently\r\n'
def test_parse_4(): s = HttpServer() with pytest.raises(BadRequestError): s._process_request("GET/uri/HTTP/1.0")
def test_parse_3(): s = HttpServer() with pytest.raises(NotHTTP1_1Error): s._process_request("GET /uri/ HTTP/1.0")
def test_parse_2(): s = HttpServer() with pytest.raises(NotGETRequestError): s._process_request("POST /uri/ HTTP/1.1")