123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import os
- import shutil
- import unittest
- from pycs import app
- from pycs import db
- from pycs import settings
- from pycs.frontend.WebServer import WebServer
- from pycs.database.Database import Database
- server = None
- class BaseTestCase(unittest.TestCase):
- def setUp(self, discovery: bool = True):
- global server
- app.config["TESTING"] = True
- self.projects_dir = app.config["TEST_PROJECTS_DIR"] = "test_projects"
- app.config["WTF_CSRF_ENABLED"] = False
- app.config["DEBUG"] = False
- app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///"
- db.create_all()
- self.client = app.test_client()
- if server is None:
- server = WebServer(app, settings)
- server.start_runner()
- # create database
- self.database = Database(discovery=discovery)
- def tearDown(self):
- global server
- server.stop_runner()
- if os.path.exists(self.projects_dir):
- shutil.rmtree(self.projects_dir)
- db.drop_all()
- def wait_for_coroutines(self):
- server.wait_for_runner()
|