Exemple #1
0
def test_get_env_var(env_var):
    with patch.dict(os.environ, {"KARMABOT_TEST_MODE": env_var}):
        assert get_env_var("KARMABOT_TEST_MODE") == env_var
Exemple #2
0
def test_return_default_value_if_env_variable_not_set():
    with patch.dict(os.environ, {}, clear=True):
        assert get_env_var("KARMABOT_TEST_MODE", default="false") == "false"
Exemple #3
0
def test_exception_env_variable_not_found():
    with patch.dict(os.environ, {}, clear=True):
        with pytest.raises(KeyError):
            get_env_var("KARMABOT_TEST_MODE")
Exemple #4
0
def test_exception_env_variable_empty():
    with patch.dict(os.environ, {"KARMABOT_TEST_MODE": ""}):
        with pytest.raises(ValueError):
            get_env_var("KARMABOT_TEST_MODE")
Exemple #5
0
def _get_admins() -> str:
    admins_env = get_env_var("KARMABOT_ADMINS", default=KARMABOT_ID).split(",")
    admins = ", ".join(f"<@{admin}>" for admin in admins_env)
    return " and".join(admins.rsplit(",", maxsplit=1))