예제 #1
0
    def setUp(self):
        app = create_app('test')
        self.app_context = app.app_context()
        self.app_context.push()

        client = app.test_client()
        self.client = client
예제 #2
0
 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)
예제 #3
0
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
예제 #4
0
    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()
예제 #5
0
    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()
예제 #6
0
 def setUp(self):
     app = create_app('test')
     self.app_context = app.app_context()
     self.app_context.push()
예제 #7
0
    # 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()