コード例 #1
0
ファイル: test_admin.py プロジェクト: pilosus/PilosusBot
    def setUp(self):
        # create an app with testing config
        self.app = create_app('testing')

        # push context
        self.app_context = self.app.app_context()
        self.app_context.push()

        # create all db
        db.create_all()

        # pre-fill db with minimal needed things
        Role.insert_roles()
        Language.insert_basic_languages()

        # werkzeug test client
        self.client = self.app.test_client(use_cookies=True)
コード例 #2
0
    def setUp(self):
        """Method called before each unit-test"""
        # create app, set TESTING flag to disable error catching
        self.app = create_app('testing')

        # push app context
        self.app_context = self.app.app_context()
        self.app_context.push()

        # create databases, see config.py for testing db settings
        db.create_all()

        # pre-fill db with minimal needed things
        Role.insert_roles()
        Language.insert_basic_languages()

        # Werkzeug Client to make requests
        self.client = self.app.test_client(use_cookies=True)
コード例 #3
0
    def setUp(self):
        """Method called before each unit-test"""
        # create app, set TESTING flag to disable error catching
        self.app = create_app('testing')

        # push app context
        self.app_context = self.app.app_context()
        self.app_context.push()

        # make celery tasks eager
        # celery emulates the API and behavior of AsyncResult,
        # except the result is already evaluated.
        celery.conf.update(CELERY_ALWAYS_EAGER=True)

        # create databases, see config.py for testing db settings
        db.create_all()

        # pre-fill db with minimal needed things
        Role.insert_roles()
        Language.insert_basic_languages()
        User.generate_fake(5)
コード例 #4
0
ファイル: celery_launcher.py プロジェクト: pilosus/PilosusBot
#!/usr/bin/env python
"""
Create a Flask application and push an application context,
which will be set throughout the entire life of the process.

Celery needs access to celery instance in order to use Celery
configuration set up using app's config file,  which in turn
uses dotenv (environment variables).

Celery workers should be launched as follows:
(venv) $ celery -A celery_launcher.celery worker -Q assess -l info --hostname=assess-server@%h
(venv) $ celery -A celery_launcher.celery worker -Q select -l info --hostname=select-server@%h
(venv) $ celery -A celery_launcher.celery worker -Q send -l info --hostname=send-server@%h
"""

import os
from PilosusBot import celery, create_app

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
app.app_context().push()
コード例 #5
0
ファイル: test_utils.py プロジェクト: pilosus/PilosusBot
 def create_app(self):
     """Mandatory method for Flask-Testing returning app instance"""
     return create_app('testing')