Пример #1
0
def demo():
    app = app_maker()

    with app.app_context():
        app.try_trigger_before_first_request_functions()
        create_demo_db(db.session)

    click.echo("demo data inserted in the database")
Пример #2
0
def webapp():
    app = app_maker(
        config={
            "TESTING": True,
            "SQLALCHEMY_DATABASE_URI": "sqlite://",
            "SQLALCHEMY_TRACK_MODIFICATIONS": False,
        }
    )
    with app.app_context():
        app.try_trigger_before_first_request_functions()
        yield app
Пример #3
0
def adduser(username):
    app = app_maker()

    with app.app_context():
        app.try_trigger_before_first_request_functions()
        user = user_datastore.find_user(username=username)
        if user is None:
            user = user_datastore.create_user(username=username,
                                              password=getpass())

        msg = ""
        if click.confirm("Give admin rights?"):
            msg = "with admin rights"
            role = user_datastore.find_role("admin")
            user_datastore.add_role_to_user(user=user, role=role)

        click.echo(f"User {username} added {msg}")
        db.session.commit()
Пример #4
0
def web(host, port, debug):
    app = app_maker()
    app.run(debug=debug, port=port, host=host)
Пример #5
0
def test_exception_is_raised_when_db_config_is_missing():
    with raises(ConfigException):
        app_maker(config={
            "TESTING": True,
            "SQLALCHEMY_TRACK_MODIFICATIONS": False,
        })