Example #1
0
def test_script_info_load_app_no_app(app: Mock) -> None:
    info = ScriptInfo(None)
    os.environ.pop("QUART_APP", None)
    with pytest.raises(NoAppException):
        info.load_app()
Example #2
0
@click.pass_obj
def clear_properties(obj, banned, favorite) -> None:
    """Delete all properties."""
    obj.property_service.clear_properties(banned, favorite)


def create_app_wrapper(*args, **kwargs):
    ctx = click.get_current_context().find_root()
    container = ctx.obj
    return create_app(container)


@main.group(
    cls=QuartGroup,
    create_app=create_app_wrapper,
    context_settings={"obj": ScriptInfo(create_app=create_app_wrapper)},
)
def server():
    """Run the crib server."""
    pass


@server.command()
@click.pass_context
def run(ctx):
    app = ctx.ensure_object(ScriptInfo).load_app()
    app.run(debug=True)


@server.command()
@click.argument("username")
Example #3
0
def test_script_info_load_app(app: Mock) -> None:
    info = ScriptInfo("module:app")
    assert info.load_app() == app
Example #4
0
 def wrapper(info: ScriptInfo, *args: Any, **kwargs: Any) -> Any:
     app = info.load_app()
     context = {}
     context.update(app.make_shell_context())
     return func(app, *args, **kwargs)