def init_celery_flask_app(**kwargs): """Create the Flask app after forking a new worker. This is to make sure no resources are shared between processes. """ app = create_app() app.app_context().push()
def create(group): app = current_app or create_app() group.app = app @app.shell_context_processor def shell_context(): from redash import models return dict(models=models) return app
def setUp(self): self.app = create_app() self.db = db self.app.config['TESTING'] = True self.app_ctx = self.app.app_context() self.app_ctx.push() db.session.close() db.drop_all() db.create_all() self.factory = Factory() self.client = self.app.test_client()
def setUp(self): self.app = create_app() self.db = db self.app.config['TESTING'] = True self.app.config['SERVER_NAME'] = 'localhost' self.app_ctx = self.app.app_context() self.app_ctx.push() db.session.close() db.drop_all() db.create_all() self.factory = Factory() self.client = self.app.test_client()
def create(group): app = current_app or create_app() group.app = app @app.shell_context_processor def shell_context(): from redash import models, settings return { 'models': models, 'settings': settings, } return app
def test_render(self): app = create_app() with app.app_context(): d = { "failures": [{ "id": 1, "name": "Failure Unit Test", "failed_at": "May 04, 2021 02:07PM UTC", "failure_reason": "", "failure_count": 1, "comment": None }] } html, text = [ render_template("emails/failures.{}".format(f), d) for f in ["html", "txt"] ] self.assertIn('Failure Unit Test', html) self.assertIn('Failure Unit Test', text)
def init_celery_flask_app(**kwargs): app = create_app() app.app_context().push()
# -*- coding: utf-8 -*- from redash import create_app app = create_app()
def add_periodic_tasks(sender, **kwargs): app = create_app() periodic_tasks = getattr(app, 'periodic_tasks', {}) for params in periodic_tasks.values(): sender.add_periodic_task(**params)
def __call__(self, *args, **kwargs): app = create_app() with app.app_context(): return TaskBase.__call__(self, *args, **kwargs)
from redash import create_app app = create_app()
def __call__(self, *args, **kwargs): if not has_app_context(): flask_app = current_app or create_app() self.app_ctx = flask_app.app_context() self.app_ctx.push() return super(BaseTask, self).__call__(*args, **kwargs)
def create(group): app = create_app() group.app = app return app