def setUp(self): app = create_app('test') self.app_context = app.app_context() self.app_context.push() client = app.test_client() self.client = client
def setUp(self): app = create_app('test') self.context = app.app_context() self.context.push() from main.orm.db import engine self.engine = engine Base.metadata.create_all(engine)
def main(config): from main.web.app import create_app if config not in ('production', 'local', 'development', 'test'): config = 'developement' app = create_app(config) return app
def setUp(self): self.app = create_app('test') self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client() from main.orm.db import engine self.engine = engine Base.metadata.create_all(engine) u = DBUser(username='******', email='*****@*****.**', password='******') u.save()
def setUp(self): app = create_app('test') self.app_context = app.app_context() self.app_context.push() self.client = app.test_client() from main.orm.db import engine self.engine = engine Base.metadata.create_all(self.engine) # set up user for authentication without admin user = User(username=admin['username'], email=admin['email'], password=admin['password']) user.save()
def setUp(self): app = create_app('test') self.app_context = app.app_context() self.app_context.push()
# add app context to celery task celery = Celery(app.name, backend=app.config['CELERY_RESULT_BACKEND'], broker=app.config['CELERY_BROKER_URL']) # assume data size is small celery.conf.beat_schedule = { 'daily-process-image': { 'task': 'main.tasks.images.image_process_task', 'schedule': crontab(hour='*/24'), } } class ContextTask(celery.Task): def __call__(self, *args, **kwargs): with app.app_context(): return self.run(*args, **kwargs) celery.Task = ContextTask return celery # TODO: replace app type with production app = create_app('test') celery = make_celery(app) from .images import image_process_task if __name__ == '__main__': celery.start()