|
@@ -5,6 +5,7 @@ import eventlet
|
|
|
import typing as T
|
|
|
|
|
|
from unittest import mock
|
|
|
+from pathlib import Path
|
|
|
|
|
|
from pycs import app
|
|
|
from pycs import db
|
|
@@ -30,16 +31,18 @@ class BaseTestCase(unittest.TestCase):
|
|
|
_sleep_time = 0.2
|
|
|
server = None
|
|
|
|
|
|
+ DB_FILE = Path.cwd() / "test.sqlite"
|
|
|
+
|
|
|
@classmethod
|
|
|
def setUpClass(cls, discovery: bool = False):
|
|
|
global server
|
|
|
- PipelineCache.CLOSE_TIMER = 2
|
|
|
app.config["TESTING"] = True
|
|
|
app.config["WTF_CSRF_ENABLED"] = False
|
|
|
app.config["DEBUG"] = False
|
|
|
- app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///"
|
|
|
+ app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{cls.DB_FILE}"
|
|
|
|
|
|
if server is None:
|
|
|
+ settings["pipeline_cache_time"] = 2
|
|
|
server = WebServer(app, settings, discovery)
|
|
|
|
|
|
if cls.server is None:
|
|
@@ -52,7 +55,7 @@ class BaseTestCase(unittest.TestCase):
|
|
|
cls.server.pipelines.start()
|
|
|
|
|
|
|
|
|
- def wait_for_bg_jobs(self):
|
|
|
+ def wait_for_bg_jobs(self, raise_errors=True):
|
|
|
|
|
|
# wait for JobRunner jobs to finish
|
|
|
while True:
|
|
@@ -63,6 +66,10 @@ class BaseTestCase(unittest.TestCase):
|
|
|
ready = False
|
|
|
break
|
|
|
|
|
|
+ if raise_errors:
|
|
|
+ self.assertTrue(job.exception is None,
|
|
|
+ job.exception)
|
|
|
+
|
|
|
if ready:
|
|
|
break
|
|
|
|
|
@@ -95,7 +102,7 @@ class BaseTestCase(unittest.TestCase):
|
|
|
pass
|
|
|
|
|
|
def tearDown(self):
|
|
|
- self.wait_for_bg_jobs()
|
|
|
+ self.wait_for_bg_jobs(raise_errors=False)
|
|
|
|
|
|
self.context.pop()
|
|
|
|