예제 #1
0
def app():
    """Create and configure a new app instance for each test."""
    app = create_app({
        "TESTING": True,
        "SECRET_KEY": "TeStKeY",
    })
    yield app
예제 #2
0
class TestFactory:
    """Factory"""
    app = create_app({
        "TESTING": True,
        "RHHR_API_ENABLED": True,
        "SQLALCHEMY_TRACK_MODIFICATIONS": True,
    })

    def test_config(self):
        """Test create_app w/o `testing` config"""
        assert not create_app().testing

    def test_testing_config(self):
        """Test create_app w/ `testing` config"""
        assert create_app({"TESTING": True}).testing

    def test_testing_app(self, app):
        """Testing app ist configured for testing"""
        assert app.testing
예제 #3
0
from __future__ import absolute_import
import os
from rune import celery, create_app
from celery import Celery, Task
from dotenv import load_dotenv

# To run the worker use the following command
#    `celery -A rune.celery_worker:celery worker -l INFO`

# Load the default config files, just like `flask run` does
load_dotenv('.flaskenv')
load_dotenv('.env')

app = create_app()
app.app_context().push()


def make_celery(app):
    celery = Celery(app.import_name,
                    backend=app.config['RESULT_BACKEND'],
                    broker=app.config['BROKER_URL'],
                    include=[rune_app for rune_app in app.rune_apps])
    celery.conf.update(app.config)

    class ContextTask(Task):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.test_request_context():
                res = self.run(*args, **kwargs)
                return res
예제 #4
0
 def test_testing_config(self):
     """Test create_app w/ `testing` config"""
     assert create_app({"TESTING": True}).testing
예제 #5
0
 def test_config(self):
     """Test create_app w/o `testing` config"""
     assert not create_app().testing
예제 #6
0
파일: wsgi.py 프로젝트: yongheshinian/rune
from dotenv import load_dotenv

from rune import create_app

# Load the default config files, just like `flask run` does
load_dotenv('.flaskenv')
load_dotenv('.env')


application = app = create_app()