示例#1
0
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
示例#2
0
文件: test_model.py 项目: yoophi/todo
    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()
示例#3
0
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'])
示例#4
0
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
示例#5
0
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)
示例#6
0
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)
示例#7
0
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()
示例#8
0
def test_config():
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
示例#9
0
from todo import create_app
app = create_app()

if __name__ == '__main__':
    app.run()
示例#10
0
# -*- 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'))
示例#11
0
 def create_app(self):
     return todo.create_app('testing')
示例#12
0
#! /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()
示例#13
0
 def setUp(self):
     self.app = create_app('TES')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
示例#14
0
文件: manage.py 项目: yoophi/todo
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
示例#15
0
 def setUp(self):
     app = todo.create_app()
     self.app = app.test_client()
示例#16
0
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()
示例#17
0
from todo import create_app, db
from flask_migrate import Migrate

app = create_app('default')
migrate = Migrate(app, db)
示例#18
0
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()   
示例#19
0
def app():
    return create_app("test")
示例#20
0
 def setUp(self):
     app = create_app('testing')
     self.app = app.test_client()
    
     db_proxy.create_tables([User, Todo], safe=True)
示例#21
0
文件: wsgi.py 项目: l769829723/todo
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')
示例#22
0
# -*- 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