Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_missing_env_var_raise_exception_correctly(mocker):
"""Verifies that an expection is thrown when necessary env vars are missing."""
os_mocked = mocker.patch("mkmsdk.utils.os")
os_mocked.environ = {}
with pytest.raises(exceptions.MissingEnvVar):
get_mkm_app_secret()
def test_missing_config():
"""Test error string is formatted correctly"""
error = MissingEnvVar("client_id")
assert str(error) == "Missing client_id environment variable"
def _get_env_var(key):
try:
return os.environ[key]
except KeyError:
raise exceptions.MissingEnvVar(key)