def test_dev_config(self): app = create_app("appname.settings.DevConfig", "dev") assert app.config["DEBUG"] == True assert app.config["SQLALCHEMY_DATABASE_URI"] == "sqlite://example.db" assert app.config["SQLALCHEMY_ECHO"] == True assert app.config["CACHE_TYPE"] == "null"
def test_prod_config(self): """ Tests if the production config loads correctly """ app = create_app('appname.settings.ProdConfig') assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'simple'
def test_dev_config(): app = create_app('appname.settings.DevConfig', 'dev') assert app.config['DEBUG'] == True assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite://example.db' assert app.config['SQLALCHEMY_ECHO'] == True assert app.config['CACHE_TYPE'] == 'null'
def test_test_config(self): """ Tests if the test config loads correctly """ app = create_app('appname.settings.TestConfig') assert app.config['DEBUG'] is True assert app.config['CACHE_TYPE'] == 'null'
def test_dev_config(self): app = create_app('appname.settings.DevConfig', env='dev') assert app.config['DEBUG'] is True assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['SQLALCHEMY_ECHO'] is True assert app.config['CACHE_TYPE'] == 'null'
def test_prod_config(self): """ Tests if the production config loads correctly """ app = create_app('appname.settings.ProdConfig') assert app.config['DEBUG'] is False assert app.config['CACHE_TYPE'] == 'redis'
def test_prod_config(self): """ Tests if the production config loads correctly """ app = create_app('appname.settings.ProdConfig', env='prod') assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'simple'
def test_dev_config(self): app = create_app('appname.settings.DevConfig', env='dev') assert app.config['DEBUG'] is True assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['SQLALCHEMY_ECHO'] is True assert app.config['CACHE_TYPE'] == 'null'
def test_test_config(self): """ Tests if the test config loads correctly """ app = create_app('appname.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('appname.settings.DevConfig') assert app.config['DEBUG'] is True assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'null'
def test_prod_config(self): """ Tests if the production config loads correctly """ app = create_app('appname.settings.ProdConfig', env='prod') assert app.config['SQLALCHEMY_DATABASE_URI'] == \ 'sqlite:///' + os.path.join(basedir, 'database.db') assert app.config['CACHE_TYPE'] == 'simple'
def setup(self): app = create_app('appname.settings.DevConfig', env='dev') self.app = app.test_client() db.app = app db.create_all() admin = User('admin', 'supersafepassword') db.session.add(admin) db.session.commit()
def setUp(self): app = create_app(TESTING=True) self.app = app.test_client() self.ctx = app.test_request_context() self.ctx.push() db.app = app db.create_all() self.cwd = os.path.dirname(os.path.realpath(__file__)) self.create_fixtures()
def test_dev_config(self): """ Tests if the development config loads correctly """ app = create_app('appname.settings.DevConfig') assert app.config['DEBUG'] is True assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'simple'
def testapp(request): app = create_app('appname.settings.Config') app.test_client_class = TestClient app.response_class = JSONResponse # client = app.test_client() db.app = app setup_db(app, db) db.create_all() update_perms(db) def teardown(): with app.app_context(): db.session.remove() db.drop_all() request.addfinalizer(teardown) return app
def testapp(request): app = create_app('appname.settings.TestConfig', env='dev') 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
def testapp(request): app = create_app('appname.settings.TestConfig') client = app.test_client() db.app = app db.create_all() if getattr(request.module, "create_user", True): admin = User('*****@*****.**', 'supersafepassword', admin=True) user = User('*****@*****.**', 'safepassword') db.session.add_all([admin, user]) db.session.commit() def teardown(): db.session.remove() db.drop_all() request.addfinalizer(teardown) return client
#!/usr/bin/env python import os from datetime import datetime from flask.ext.script import Manager, Server from flask.ext.script.commands import ShowUrls, Clean from appname import create_app from appname.database import db from appname.main.models import User, Role # default to dev config because no one should use this in # production anyway env = os.environ.get('APPNAME_ENV', 'dev') app = create_app('appname.settings.{}Config'.format(env.capitalize())) manager = Manager(app) manager.add_command("server", Server()) manager.add_command("show-urls", ShowUrls()) manager.add_command("clean", Clean()) @manager.shell def make_shell_context(): """ Creates a python REPL with several default imports in the context of the app """ return dict(app=app, db=db, User=User)
#!/usr/bin/env python import os from flask.ext.script import Manager, Server from flask.ext.script.commands import ShowUrls, Clean from appname import create_app from appname.models import db, User # default to dev config because no one should use this in # production anyway env = os.environ.get('APPNAME_ENV', 'dev') application = create_app('appname.settings.%sConfig' % env.capitalize(), env=env) manager = Manager(application) manager.add_command("server", Server()) manager.add_command("show-urls", ShowUrls()) manager.add_command("clean", Clean()) @manager.shell def make_shell_context(): """ Creates a python REPL with several default imports in the context of the app """ return dict(app=app, db=db, User=User) @manager.command def createdb():
def test_prod_config(self): app = create_app('appname.settings.ProdConfig', env='prod') assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'simple'
import os from appname import create_app # Defaults to development environment env = os.environ.get('APPNAME_ENV', 'development') app = create_app('appname.config.%sConfig' % env.capitalize(), env=env) app.run(debug=True)
def test_client(request): app = create_app('appname.config.TestingConfig', env='testing') client = app.test_client() return client
#!/usr/bin/env python import os from flask.ext.script import Manager, Server from flask.ext.script.commands import ShowUrls, Clean from appname import create_app from appname.models import db, User # default to dev config because no one should use this in # production anyway env = os.environ.get('APPNAME_ENV', 'dev') app = create_app('appname.settings.%sConfig' % env.capitalize(), env=env) manager = Manager(app) manager.add_command("server", Server()) manager.add_command("show-urls",ShowUrls()) manager.add_command("clean",Clean()) @manager.shell def make_shell_context(): """ Creates a python REPL with several default imports in the context of the app """ return dict(app=app, db=db, User=User) @manager.command def createdb(): """ Creates a database with all of the tables defined in
def test_prod_config(self): app = create_app("appname.settings.ProdConfig", "prod") assert app.config["SQLALCHEMY_DATABASE_URI"] == "postgresql://localhost/example" assert app.config["CACHE_TYPE"] == "simple"
from pytz import timezone from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.jobstores.mongodb import MongoDBJobStore, MongoClient from apscheduler.executors.pool import ThreadPoolExecutor from appname import create_app app = create_app('appname.config.BaseConfig') jobstores = { 'default': MongoDBJobStore(client=MongoClient(app.config.get('MONGO_URI'))), } executors = {'default': ThreadPoolExecutor(20)} job_defaults = {'coalesce': False, 'max_instances': 5} scheduler_tz = timezone(app.config["TIME_ZONE"]) scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=scheduler_tz) scheduler.start() app.scheduler = scheduler
def test_prod_config(self): app = create_app('appname.settings.ProdConfig', env='prod') assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' assert app.config['CACHE_TYPE'] == 'simple'
def setup(self): app = create_app('appname.settings.DevConfig', env='dev') self.app = app.test_client() db.app = app db.create_all()
def setup(self): app = create_app("appname.settings.DevConfig", env="dev") self.app = app.test_client() db.app = app db.create_all()
def test_test_config(self): """Tests test config loads correctly.""" app = create_app('appname.config.TestingConfig', env='testing') assert app.config['DEBUG'] is False
def test_dev_config(self): """Tests development config loads correctly.""" app = create_app('appname.config.DevelopmentConfig', env='development') assert app.config['DEBUG'] is True
def test_prod_config(self): """Tests production config loads correctly.""" app = create_app('appname.config.ProductionConfig', env='production')
#!/usr/bin/env python from flask_migrate import MigrateCommand from flask_script import Manager, Server from appname import create_app from appname.models import db, User app = create_app() manager = Manager(app) manager.add_command("server", Server()) 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 """ return dict(app=app, db=db, User=User) if __name__ == "__main__": manager.run()
#!/usr/bin/env python import os from flask_script import Manager, Server, prompt_choices from flask_script.commands import ShowUrls, Clean from flask_migrate import Migrate, MigrateCommand from appname import create_app from appname.warmup import setup_db, update_perms from appname.models import db, User # default to dev config because no one should use this in # production anyway app = create_app('appname.settings.Config') manager = Manager(app) @manager.shell def make_shell_context(): """ Creates a python REPL with several default imports in the context of the app """ return dict(app=app, db=db, User=User) @manager.command def create_db(): ''' create database and tables ''' setup_db(app, db)
def test_prod_config(): app = create_app('appname.settings.ProdConfig', 'prod') assert app.config['SQLALCHEMY_DATABASE_URI'] == 'postgresql://localhost/example' assert app.config['CACHE_TYPE'] == 'simple'
#!/usr/bin/env python3 """ For WSGI Server To run: $ gunicorn -b 0.0.0.0:5000 wsgi:app OR $ export FLASK_APP=wsgi $ flask run """ import os from appname import create_app env = os.environ.get('APPNAME_ENV', 'dev') app = create_app('appname.settings.%sConfig' % env.capitalize())
#coding:utf-8 import appname app = appname.create_app('appname.settings.DevConfig', env='dev') #app.run(port=10000, debug=True)