def test_read_yaml(self):
        path = 'flask_site/config/config.yml'
        config = read_yaml(path)

        ok_(isinstance(config, dict),
            msg='Returned object must be instance of dict')
        ok_(len(config.keys()) > 0, msg='Returned object must not be empty.')
 def test_read_yaml_imaginary_file_should_raises_error(self):
     path = '/a/b/c/d/e/f/g/h/__i.yml'
     read_yaml(path)
Example #3
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')
    def test_read_yaml(self):
        path = 'flask_site/config/config.yml'
        config = read_yaml(path)

        ok_(isinstance(config, dict), msg='Returned object must be instance of dict')
        ok_(len(config.keys()) > 0, msg='Returned object must not be empty.')
 def test_read_yaml_imaginary_file_should_raises_error(self):
     path = '/a/b/c/d/e/f/g/h/__i.yml'
     read_yaml(path)
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']