def test_prod_config(self): """ Tests if the production config loads correctly """ app = create_app('flaskheartbeat.settings.ProdConfig') assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'simple'
def test_test_config(self): """ Tests if the test config loads correctly """ app = create_app('flaskheartbeat.settings.TestConfig') assert app.config['DEBUG'] is True assert app.config['SQLALCHEMY_ECHO'] is True assert app.config['CACHE_TYPE'] == 'null'
def test_dev_config(self): """ Tests if the development config loads correctly """ app = create_app('flaskheartbeat.settings.DevConfig') assert app.config['DEBUG'] is True assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'null'
def testapp(request): app = create_app('flaskheartbeat.settings.TestConfig') client = app.test_client() db.app = app db.create_all() if getattr(request.module, "create_user", True): admin = User('admin', 'supersafepassword') db.session.add(admin) db.session.commit() def teardown(): db.session.remove() db.drop_all() request.addfinalizer(teardown) return client
#!/usr/bin/env python import os from flask.ext.script import Manager, Server from flask.ext.script.commands import ShowUrls, Clean from flaskheartbeat import create_app from flaskheartbeat.models import db, User from flask_migrate import Migrate, MigrateCommand # default to dev config because no one should use this in # production anyway env = os.environ.get('FLASKHEARTBEAT_ENV', 'dev') app = create_app('flaskheartbeat.settings.%sConfig' % env.capitalize()) manager = Manager(app) manager.add_command("server", Server()) manager.add_command("show-urls", ShowUrls()) manager.add_command("clean", Clean()) #Migration stuff migrate = Migrate(app, db) manager.add_command("db", MigrateCommand) @manager.shell def make_shell_context(): """ Creates a python REPL with several default imports in the context of the app """