コード例 #1
0
def testapp(request):
    app = create_app('impression.settings.TestConfig')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        admin = User(username="******", password="******")
        admin.insert()
        my_role = Role(name='admin')
        my_role.insert()
        admin.add_roles('admin')

        non_admin = User(username="******", password="******")
        non_admin.insert()

        safe_commit()

    def teardown():
        db.session.remove()
        db.drop_all()

    request.addfinalizer(teardown)

    return client
コード例 #2
0
ファイル: manage.py プロジェクト: smeggingsmegger/impression
def createdb():
    """
    Creates a database with all of the tables defined in
    the models file.
    """

    db.create_all()
    db.session.commit()