Ejemplo n.º 1
0
def test_curl_put_get():
    with files_server() as (server, directory):
        server_url = server.application_url
        path = os.path.join(directory, "test_for_GET")
        request_url = u"%s?path=%s" % (server_url, path)

        input = os.path.join(directory, "input")
        output = os.path.join(directory, "output")
        open(input, "w").write(u"helloworld")

        post_file(request_url, input)
        get_file(request_url, output)
        assert open(output, "r").read() == u"helloworld"
Ejemplo n.º 2
0
def test_curl_put_get():
    with files_server() as (server, directory):
        server_url = server.application_url
        path = os.path.join(directory, "test_for_GET")
        request_url = u"%s?path=%s" % (server_url, path)

        input = os.path.join(directory, "input")
        output = os.path.join(directory, "output")
        open(input, "w").write(u"helloworld")

        post_file(request_url, input)
        get_file(request_url, output)
        assert open(output, "r").read() == u"helloworld"
Ejemplo n.º 3
0
def test_curl_status_code():
    with files_server() as (server, directory):
        server_url = server.application_url
        path = os.path.join(directory, "test_for_GET")
        request_url = u"%s?path=%s" % (server_url, path)
        # Verify curl doesn't just silently swallow errors.
        exception_raised = False
        try:
            get_file(request_url, os.path.join(directory, "test"))
        except Exception:
            exception_raised = True
        assert exception_raised

        post_request_url = u"%s?path=%s" % (server_url, "/usr/bin/cow")
        exception_raised = False
        try:
            post_file(post_request_url, os.path.join(directory, "test"))
        except Exception:
            exception_raised = True
        assert exception_raised
Ejemplo n.º 4
0
def test_curl_status_code():
    with files_server() as (server, directory):
        server_url = server.application_url
        path = os.path.join(directory, "test_for_GET")
        request_url = u"%s?path=%s" % (server_url, path)
        # Verify curl doesn't just silently swallow errors.
        exception_raised = False
        try:
            get_file(request_url, os.path.join(directory, "test"))
        except Exception:
            exception_raised = True
        assert exception_raised

        post_request_url = u"%s?path=%s" % (server_url, "/usr/bin/cow")
        exception_raised = False
        try:
            post_file(post_request_url, os.path.join(directory, "test"))
        except Exception:
            exception_raised = True
        assert exception_raised