summaryrefslogtreecommitdiff
path: root/jimbrella/test/test_routine.py
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-02-03 16:11:20 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-02-03 16:11:20 +0800
commit616116a84120220adb8e36cb364f08b0a638807e (patch)
tree6b71440277584b72f49c20667fa1a3d6d9875659 /jimbrella/test/test_routine.py
parent3d30bce15559afdf3acf6277648231611e145037 (diff)
Adapt test suites
Diffstat (limited to 'jimbrella/test/test_routine.py')
-rw-r--r--jimbrella/test/test_routine.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/jimbrella/test/test_routine.py b/jimbrella/test/test_routine.py
index 0b15717..acb1f1e 100644
--- a/jimbrella/test/test_routine.py
+++ b/jimbrella/test/test_routine.py
@@ -5,20 +5,19 @@ import os
import shutil
import logging
from .jform_data import mock_jform_data
-from ..routine import sync_database, process_overdue
-from ..database import Database
+from ..routine import sync_jform, process_overdue
+from ..umbrellas import Umbrellas
from ..jform import JForm
from ..admin_log import AdminLog
from ..config import *
-"""Set up logging."""
+"""Set up logging.
logging.basicConfig(
filename="/tmp/jimbrella.log",
encoding="utf-8",
level=logging.INFO,
format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s",
-)
-logging.info("----- BEGIN ROUTINE TEST -----")
+)"""
"""Spin up a simple Flask app to mimic jForm."""
jform = Flask(__name__)
@@ -58,18 +57,21 @@ def api(endpoint):
Thread(target=jform.run, kwargs={"port": 5001}).start()
-"""Initialize Database and JForm."""
-TEST_DATABASE_PATH = "/tmp/jimbrella.db.csv"
-TEST_ADMIN_LOG_PATH = "/tmp/jimbrella.admin.log"
-shutil.copyfile(DATABASE_PATH, TEST_DATABASE_PATH)
-db = Database(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)
-sync_database(takeaway_jform, giveback_jform, db, admin)
-process_overdue(db)
+if __name__ == "__main__":
+ logging.info("----- BEGIN ROUTINE TEST -----")
+
+ """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)
+ 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)
-logging.info("----- END ROUTINE TEST -----")
+ """Cleanup"""
+ os.remove(takeaway_jform._bookmark_fp)
+ os.remove(giveback_jform._bookmark_fp)
+ logging.info("----- END ROUTINE TEST -----")