Example #1
0
def test_reload():
    async_server = WheatServer("", "--worker-type %s" % "AsyncWorker",
                               "--app-project-path %s" % os.path.join(PROJECT_PATH, "example"))
    time.sleep(0.5)
    os.kill(async_server.exec_pid, signal.SIGHUP)
    s = server_socket(10829)

    s.send(construct_command("stat", "master"))
    assert "Total workers spawned: 8" in s.recv(1000)
Example #2
0
def test_reload():
    async_server = WheatServer(
        "reload.conf", "--worker-type %s" % "AsyncWorker",
        "--app-project-path %s" % os.path.join(PROJECT_PATH, "example"),
        "--protocol Http")
    time.sleep(1)
    os.kill(async_server.exec_pid, signal.SIGHUP)
    s = server_socket(10829)

    s.send(construct_command("stat", "master"))
    assert "Total spawn workers: 8" in s.recv(1000)
Example #3
0
def test_get_two():
    async = WheatServer("", "--worker-type %s" % "AsyncWorker",
                               "--app-project-path %s" % os.path.join(PROJECT_PATH, "example"),
                               "--static-file-root %s" % os.path.join(PROJECT_PATH, "example/"),
                               "--allowed-extension bmp,gif")
    time.sleep(0.1)
    s = server_socket(10828)
    s.send("GET / HTTP/1.1\r\nHOST: localhost:10828\r\nConnec")
    time.sleep(0.2)
    s.send("tion: close\r\n\r\n")
    a = s.recv(100)
    assert "200" in a
Example #4
0
def test_get_two():
    async = WheatServer(
        "", "--worker-type %s" % "AsyncWorker",
        "--app-project-path %s" % os.path.join(PROJECT_PATH, "example"),
        "--document-root %s" % os.path.join(PROJECT_PATH, "example/"),
        "--allowed-extension bmp,gif", "--protocol Http")
    time.sleep(0.1)
    s = server_socket(10828)
    s.send("GET / HTTP/1.1\r\nHOST: 127.0.0.1:10828\r\nConnec")
    time.sleep(0.2)
    s.send("tion: close\r\n\r\n")
    a = s.recv(100)
    assert "200" in a
Example #5
0
def test_post_file():
    async = WheatServer("", "--worker-type %s" % "AsyncWorker",
                               "--app-project-path %s" % os.path.join(PROJECT_PATH, "example"),
                               "--static-file-root %s" % os.path.join(PROJECT_PATH, "example/"),
                               "--allowed-extension bmp,gif")
    time.sleep(0.1)
    s = server_socket(10828)
    s.settimeout(0.5)
    s.send(POST_DATA[:302])
    time.sleep(0.1)
    try:
        a = s.recv(100)
    except:
        pass
    else:
        assert "" == a
    s.send(POST_DATA[302:])
    a = s.recv(100)
    assert "200" in a
Example #6
0
def test_post_file():
    async = WheatServer(
        "", "--worker-type %s" % "AsyncWorker",
        "--app-project-path %s" % os.path.join(PROJECT_PATH, "example"),
        "--document-root %s" % os.path.join(PROJECT_PATH, "example/"),
        "--allowed-extension bmp,gif", "--protocol Http")
    time.sleep(0.1)
    s = server_socket(10828)
    s.settimeout(0.5)
    s.send(POST_DATA[:302])
    time.sleep(0.1)
    try:
        a = s.recv(100)
    except:
        pass
    else:
        assert "" == a
    s.send(POST_DATA[302:])
    a = s.recv(1000)
    assert "200" in a and "1234" in a