def test_create_app(): """ tests application factory first assertion tests that the application configuration id noy testing when application factory is instantiated second assertion tests that the testing configuration can be initialized on the application factory when set """ assert not create_app().testing assert create_app({'TESTING': True}).testing
def setUp(self): super(TestUserModel, self).setUp() self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
def client(): app = todo.create_app() db_fd, app.config['DATABASE'] = tempfile.mkstemp() app.config['TESTING'] = True with app.test_client() as client: with app.app_context(): todo.db.init_db() yield client os.close(db_fd) os.unlink(app.config['DATABASE'])
def app(): """ returns a instance of the application object with testing config :var app: function :rtype: object: Flask_application """ app = create_app({ 'TESTING': True, 'DATABASE': 'sqlite:///:memory:' }) return app
def app(): db_fd, db_path = tempfile.mkstemp() app = create_app({ 'TESTING': True, 'DATABASE': db_path, }) with app.app_context(): init_db() get_db().executescript(_data_sql) yield app os.close(db_fd) os.unlink(db_path)
def app(): ''' yields a Flask() object initialized with a temporary database and some test data coming from 'data.sql' ''' db_fd, db_path = tempfile.mkstemp() app = create_app({ 'TESTING': True, 'DATABASE': db_path, }) with app.app_context(): init_db() get_db().executescript(_data_sql) yield app os.close(db_fd) os.unlink(db_path)
from config import LocalConfig from todo import create_app, socketio from flask_migrate import MigrateCommand from flask_script import Manager app = create_app(LocalConfig) manager = Manager(app) manager.add_command('db', MigrateCommand) @manager.command def runserver(): return socketio.run(app) if __name__ == '__main__': manager.run()
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing
from todo import create_app app = create_app() if __name__ == '__main__': app.run()
# -*- coding: utf-8 -*- __author__ = 'florije' from todo import create_app app = create_app('development') if __name__ == '__main__': app.run(port=app.config.get('PORT'), host=app.config.get('HOST'))
def create_app(self): return todo.create_app('testing')
#! /usr/bin/env python import os from todo import create_app, db from flask_script import Manager from flask_migrate import Migrate, MigrateCommand app = create_app(os.getenv('TODO_ENV') or 'development') manager = Manager(app) migrate = Migrate(app, db) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
def setUp(self): self.app = create_app('TES') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
from flask.ext.script import Manager, Shell from flask.ext.migrate import Migrate, MigrateCommand from flask.ext.script.commands import ShowUrls from todo import create_app from todo.database import db COV = None if os.environ.get('FLASK_COVERAGE'): import coverage COV = coverage.coverage(branch=True, include='sample/*') COV.start() app = create_app(os.getenv('FLASK_CONFIG') or 'default') manager = Manager(app) migrate = Migrate(app, db) def make_shell_context(): return dict(app=app, db=db) @manager.command def test(coverage=False): """Run the unit test.""" if coverage and not os.environ.get('FLASK_COVERAGE'): import sys
def setUp(self): app = todo.create_app() self.app = app.test_client()
from todo import create_app, init_celery, celery from todo.cli import cli_register import os from flask_swagger_ui import get_swaggerui_blueprint # Getting WORK_ENV variable and create Flask object. env = os.environ.get('WORK_ENV', 'Dev') app = create_app(f'config.{env.capitalize()}Config') # Register CLI commands cli_register(app) # Init Celery object init_celery(app, celery=celery) if __name__ == '__main__': app.run()
from todo import create_app, db from flask_migrate import Migrate app = create_app('default') migrate = Migrate(app, db)
import os from todo import create_app import todo.models as models app = create_app(os.environ.get('FLASK_CONFIG') or 'default') models.init_db() if __name__ == '__main__': app.run()
def app(): return create_app("test")
def setUp(self): app = create_app('testing') self.app = app.test_client() db_proxy.create_tables([User, Todo], safe=True)
from todo import create_app from waitress import serve app = create_app('PRO') serve(app.wsgi_app, listen='127.0.0.1:5000', url_scheme='https')
# -*- coding: utf-8 -*- __author__ = 'florije' import os from flask.ext.script import Manager, Shell, Server from flask.ext.migrate import Migrate, MigrateCommand from todo import create_app from todo.models import db app = create_app(os.getenv('FLASK_CONFIG') or 'development') manager = Manager(app) manager.add_command("runserver", Server()) manager.add_command("shell", Shell()) migrate = Migrate(app, db) def make_shell_context(): # return dict(app=app, db=db, TaskModel=TodoModel) return dict(app=app) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) @manager.command