def test_default_to_zero(mock_env): p = param.Int(default=0) value = p("LOG_LEVEL") assert value is not None assert value == 0
def test_invalid_type_error_int(mock_env): with pytest.raises(ValueError): p = param.Int() value = p("THIS_ONE")
def test_param_public_type(): integer = param.Int() assert integer.type == "Int"
def test_type_mapping_int(mock_env): integer = param.Int() value = integer("NUMBER") assert value == 60 assert type(value) is int
class EnvTestConfig(EnvConfig): TEST_VAR = param.Int(default=45) NEW_VAR = param.Str(override="SET_THIS_VAR")
class ErrConf(EnvConfig): THIS_ONE = param.Int(required=True)
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)
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)