Beispiel #1
0
def test_app_config_default_env_prefix(sanic_app: Sanic):
    environ["SANIC_PARAM1"] = "value1"
    environ["SANIC_PARAM2"] = "p2"
    environ["NON_SANIC_PARAM3"] = "p3"
    sanic_config_manager(app=sanic_app)
    assert sanic_app.config["PARAM1"] == "value1"
    assert sanic_app.config["PARAM2"] == "p2"
    with raises(expected_exception=KeyError) as e:
        _ = sanic_app.config["PARAM3"]
Beispiel #2
0
def test_app_config_custom_env_prefix(sanic_app: Sanic):
    environ["NON_SANIC_PARAM3"] = "p3"
    sanic_config_manager(app=sanic_app, prefix="NON_SANIC_")
    assert sanic_app.config["PARAM3"] == "p3"
Beispiel #3
0
from {{cookiecutter.app_name}}.{{cookiecutter.app_name}} import app
from {{cookiecutter.app_name}}.util import sanic_config_manager

sanic_config_manager(app, prefix="{{cookiecutter.sanic_env_prefix}}")


if __name__ == "__main__":
    app.run()