summaryrefslogtreecommitdiff
path: root/jimbrella
diff options
context:
space:
mode:
Diffstat (limited to 'jimbrella')
-rw-r--r--jimbrella/test/test_routine.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/jimbrella/test/test_routine.py b/jimbrella/test/test_routine.py
index acb1f1e..8d718be 100644
--- a/jimbrella/test/test_routine.py
+++ b/jimbrella/test/test_routine.py
@@ -1,5 +1,5 @@
from flask import Flask, Response, request
-from threading import Thread
+from multiprocessing import Process
import json
import os
import shutil
@@ -55,23 +55,28 @@ def api(endpoint):
return Response(giveback, content_type="application/json")
-Thread(target=jform.run, kwargs={"port": 5001}).start()
+TEST_DATABASE_PATH = "/tmp/jimbrella.db"
+TEST_ADMIN_LOG_PATH = "/tmp/jimbrella.admin.log"
+
if __name__ == "__main__":
logging.info("----- BEGIN ROUTINE TEST -----")
+ mock_jform = Process(target=jform.run, kwargs={"port": 5001})
+ mock_jform.start()
"""Initialize Database and JForm."""
- TEST_DATABASE_PATH = "/tmp/jimbrella.db"
- TEST_ADMIN_LOG_PATH = "/tmp/jimbrella.admin.log"
shutil.copyfile(DATABASE_PATH, TEST_DATABASE_PATH)
db = Umbrellas(TEST_DATABASE_PATH)
takeaway_jform = JForm("takeaway", "http://localhost:5001/takeaway", "/tmp")
giveback_jform = JForm("giveback", "http://localhost:5001/giveback", "/tmp")
admin = AdminLog(TEST_ADMIN_LOG_PATH)
+
+ """Simulate routine."""
sync_jform(takeaway_jform, giveback_jform, db, admin)
process_overdue(db, admin)
"""Cleanup"""
os.remove(takeaway_jform._bookmark_fp)
os.remove(giveback_jform._bookmark_fp)
+ mock_jform.terminate()
logging.info("----- END ROUTINE TEST -----")