예제 #1
0
def test_forbidden_error1():
    s = HttpServer()
    with pytest.raises(ForbiddenError):
        body, content_type = s._retrieve_resource(b"../../etc/password/")
예제 #2
0
def test_retrieve_resources_2():
    s = HttpServer()
    with pytest.raises(ResourceNotFound):
        s._retrieve_resource(b"afilethatdoesntexist.123")
예제 #3
0
def test_retrieve_resources_3():
    s = HttpServer()
    body, content_type = s._retrieve_resource(b"")
    assert content_type == b"text/html"
예제 #4
0
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