def c(): app_config = { 'LOGIN_DISABLED': True, 'WTF_CSRF_ENABLED': False, 'TESTING': True, 'SQLALCHEMY_DATABASE_URI': f'sqlite:///{DB_PATH}' } db_fd, app_config['DATABASE'] = tempfile.mkstemp() app = bundle_app(app_config) # FIXME: Tasks are not integration tested yet. stop_tasks() with app.test_client() as client: with app.app_context(): db.create_all() teardown_tables(copy.copy(MODULES)) fill_offices() fill_tasks() fill_users() fill_tickets() yield client register(lambda: os.path.isfile(DB_PATH) and os.remove(DB_PATH)) os.close(db_fd) os.unlink(app.config['DATABASE'])
def c(): app_config = { 'LOGIN_DISABLED': True, 'WTF_CSRF_ENABLED': False, 'TESTING': True, 'DB_NAME': DB_NAME, 'SQLALCHEMY_DATABASE_URI': f'sqlite:///{DB_PATH}' } db_fd, app_config['DATABASE'] = tempfile.mkstemp() app = bundle_app(app_config) # FIXME: Tasks are not integration tested yet. stop_tasks() with app.test_client() as client: with app.app_context(): db.create_all() teardown_tables(copy.copy(MODULES)) recreate_defaults(DEFAULT_MODULES) fill_offices() fill_tasks() fill_users() fill_tickets() fill_slides() yield client os.close(db_fd) os.unlink(app.config['DATABASE']) before_exit()
def create_db(app): ''' Creating all non-existing tables and load initial data. Parameters ---------- app: Flask app app to use its context to create tables and load initial data. ''' with app.app_context(): db.create_all() db.session.commit() mse()
def create_db(app, testing=False): ''' Creating all non-existing tables and load initial data. Parameters ---------- app: Flask app app to use its context to create tables and load initial data. testing: bool flag to disable migrations, mainly used during integration testing. ''' with app.app_context(): if not os.path.isfile(absolute_path(app.config.get('DB_NAME'))): db.create_all() else: try: database_upgrade(directory=MIGRATION_FOLDER) except Exception as exception: if not isinstance(exception, OperationalError): log_error(exception, quiet=os.name == 'nt') create_default_records()
def c(): app_config = {'LOGIN_DISABLED': True, 'WTF_CSRF_ENABLED': False, 'TESTING': True, 'DB_NAME': DB_NAME, 'SQLALCHEMY_DATABASE_URI': f'sqlite:///{DB_PATH}?check_same_thread=False'} app = bundle_app(app_config) stop_tasks() with app.test_client() as client: with app.app_context(): db.create_all() teardown_tables(copy.copy(MODULES)) recreate_defaults(DEFAULT_MODULES) fill_offices() fill_tasks() fill_users() fill_tickets() fill_slides() fill_tokens() yield client