Beispiel #1
0
def test_default(mock_env):
    p = param.Str(default="DEBUG")
    value = p("LOG_LEVEL")
    assert value == "DEBUG"
Beispiel #2
0
def test_prefix(mock_env):
    p = param.Str(prefix="THIS_")
    value = p("ONE")
    assert value == "dev"
Beispiel #3
0
def test_override(mock_env):
    p = param.Str(override="THIS_ONE")
    value = p("HOST")
    assert value == "dev"
Beispiel #4
0
def test_required_prefix(mock_env):
    p = param.Str(required=True, prefix="MY_FIRST_")
    with pytest.raises(KeyError) as e_info:
        p("APP")
    assert "MY_FIRST_APP" in str(e_info)
Beispiel #5
0
def test_not_required(mock_env):
    p = param.Str()
    value = p("PASSWORD")
    assert not value
Beispiel #6
0
def test_required(mock_env):
    p = param.Str(required=True)
    with pytest.raises(KeyError) as e_info:
        p("LOG_LEVEL")
    assert "LOG_LEVEL" in str(e_info)
Beispiel #7
0
class EnvTestConfig(EnvConfig):

    TEST_VAR = param.Int(default=45)
    NEW_VAR = param.Str(override="SET_THIS_VAR")
Beispiel #8
0
class Inherit(EnvTestConfig):

    SERVICE_VAR = param.Str()
    REMOTE_HOST = param.Str(default="no-host")
Beispiel #9
0
class DefaultAppConfig(EnvConfig):
    """App env config."""

    HOST = param.Str(required=True)
    PORT = param.Int(required=True)
    PASSWORD = param.Str(override="SECRET_REDIS_PW", required=True)
Beispiel #10
0
class AppConfig(DefaultAppConfig):

    SERVICE = param.Str(prefix="MY_APP_")
    VERSION = param.Int(default=1)
    ENV = param.Str(default="prod")
    REMOTE_HOST = param.Int(default=0)