예제 #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