Commit cf4a58bd authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

Clean shutdown and test update

parent 77b22e3e
Loading
Loading
Loading
Loading
+31 −19
Original line number Diff line number Diff line
import os
import sys
from time import sleep

sys.path.insert(0, os.getcwd())

@@ -384,6 +385,7 @@ def run(
    """
    Start both HTTP server and job workers
    """
    try:
        _check_port(host, port)
        static_dir = os.path.dirname(os.path.abspath(__file__)) + "/static/"
        http_process = Process(
@@ -403,6 +405,16 @@ def run(
            transfo_process.start()
            transfo_process.join()
        http_process.join()
    except KeyboardInterrupt:
        try:
            transfo_process.terminate()
        except NameError:
            pass
        sleep(1)
        try:
            http_process.terminate()
        except NameError:
            pass


def remove_api_access(app_uuid: str):
+4 −0
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ from circe import (
    list_transformations,
    run,
)
import sys
import os

sys.path.insert(0, os.getcwd())


def run_cli():
+5 −5
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ def test_blocking_call_to_post_job():
    job = client.new_job()
    job.add_file("test_assets/index.html")
    job.add_file("test_assets/style.css")
    job.add_transformation("html2pdf")
    job.add_transformation("sleep_well", {"time": 1})
    client.send(job, wait=True, destination_file="test_assets/result.tar.gz")
    assert job.result_file_path is not None

@@ -47,7 +47,7 @@ def test_non_blocking_call_to_post_job():
    global client
    job = client.new_job()
    job.add_file("test_assets/doc.docx")
    job.add_transformation("docx2markdown")
    job.add_transformation("sleep_well", {"time": 1})
    client.send(job)
    assert job.uuid is not None

@@ -56,7 +56,7 @@ def test_polling():
    global client
    job = client.new_job()
    job.add_file("test_assets/doc.docx")
    job.add_transformation("donothing")
    job.add_transformation("sleep_well", {"time": 5})
    client.send(job)
    client.poll(job, "test_assets/result.tar.gz")
    assert os.path.isfile("test_assets/result.tar.gz")
@@ -66,7 +66,7 @@ def test_log_presence():
    global client
    job = client.new_job()
    job.add_file("test_assets/doc.docx")
    job.add_transformation("donothing")
    job.add_transformation("sleep_well", {"time": 1})
    client.send(job, wait=True)
    file_names = []
    for file_name, _ in job.result.files:
@@ -85,6 +85,6 @@ def test_bad_auth():
        )
        job = bad_client.new_job()
        job.add_file("test_assets/doc.docx")
        job.add_transformation("donothing")
        job.add_transformation("sleep_well", {"time": 5})
        with pytest.raises(circe_client.AccessDenied) as e:
            bad_client.send(job)