def test_read_env_dev(self):
        old_argv = sys.argv

        sys.argv = ["./start.py", "development"]
        eq_(read_env(), "development", msg='The command "start development" should return development env')

        sys.argv = ["./start.py", "dev"]
        eq_(read_env(), "development", msg='The command "start dev" should return development env')

        sys.argv = ["./start.py", "debug"]
        eq_(read_env(), "development", msg='The command "start debug" should return development env')
    def test_read_env_prod(self):
        old_argv = sys.argv

        sys.argv = ["./start.py", "prod"]
        eq_(read_env(), "production", msg='The command "start prod" should return production env')

        sys.argv = ["./start.py", "production"]
        eq_(read_env(), "production", msg='The command "start production" should return production env')

        sys.argv = ["./start.py"]
        eq_(read_env(), "production", msg='The command "start" should return production env')

        sys.argv = ["./start.py", "waku"]
        eq_(read_env(), "production", msg='The command "start *" should return production env')
    def test_read_env_dev(self):
        old_argv = sys.argv

        sys.argv = ['./start.py', 'development']
        eq_(read_env(),
            'development',
            msg='The command "start development" should return development env'
            )

        sys.argv = ['./start.py', 'dev']
        eq_(read_env(),
            'development',
            msg='The command "start dev" should return development env')

        sys.argv = ['./start.py', 'debug']
        eq_(read_env(),
            'development',
            msg='The command "start debug" should return development env')
    def test_read_env_prod(self):
        old_argv = sys.argv

        sys.argv = ['./start.py', 'prod']
        eq_(read_env(),
            'production',
            msg='The command "start prod" should return production env')

        sys.argv = ['./start.py', 'production']
        eq_(read_env(),
            'production',
            msg='The command "start production" should return production env')

        sys.argv = ['./start.py']
        eq_(read_env(),
            'production',
            msg='The command "start" should return production env')

        sys.argv = ['./start.py', 'waku']
        eq_(read_env(),
            'production',
            msg='The command "start *" should return production env')
Пример #5
0
from flask import Flask

from flask.ext.assets import Environment, Bundle

from flask_site.helpers import read_yaml, read_env
from flask_site.errors import HTTPMethodNotImplementedError, ControllerNotFoundError, ConfigNotFoundError

import importlib
import os.path

main_config = read_yaml('flask_site/config/config.yml')
environment = main_config.get(read_env())
flask_config = environment.get(
    'flask'
) if environment else None  # Get config for this environment, if it exists

routes_config = read_yaml('flask_site/config/routes.yml')
bundles_config = read_yaml('flask_site/config/bundles.yml')


def create_app(config=main_config, env=environment):
    if not config:
        raise ConfigNotFoundError('Config is not available')
    if not env:
        raise ConfigNotFoundError('Environment is not set')

    app = Flask(__name__,
                template_folder=os.path.abspath('templates'),
                static_folder=os.path.abspath('static'))

    app.config['DEBUG'] = flask_config.get('debug')
Пример #6
0
from flask import Flask

from flask.ext.assets import Environment, Bundle

from flask_site.helpers import read_yaml, read_env
from flask_site.errors import HTTPMethodNotImplementedError, ControllerNotFoundError, ConfigNotFoundError

import importlib
import os.path


main_config = read_yaml('flask_site/config/config.yml')
environment = main_config.get(read_env())
flask_config = environment.get('flask') if environment else None  # Get config for this environment, if it exists

routes_config = read_yaml('flask_site/config/routes.yml')
bundles_config = read_yaml('flask_site/config/bundles.yml')


def create_app(config=main_config, env=environment):
    if not config:
        raise ConfigNotFoundError('Config is not available')
    if not env:
        raise ConfigNotFoundError('Environment is not set')

    app = Flask(__name__,
                template_folder=os.path.abspath('templates'),
                static_folder=os.path.abspath('static'))
    
    app.config['DEBUG'] = flask_config.get('debug')
    app.config['ASSETS_DEBUG'] = app.config['DEBUG']