Skip to content
Snippets Groups Projects
Commit 916b4a13 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

added exception if environment variable doesn't match existing keys

parent a46d2cd1
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -3,3 +3,5 @@
.coverage
.eggs/
*.egg-info/
__pycache__/
.cache/
......@@ -20,4 +20,8 @@ config = {
def configure_app(app):
mode = os.getenv('FRACTALIS_MODE', default='production')
app.config.from_object(config[mode])
try:
app.config.from_object(config[mode])
except KeyError as e:
raise KeyError("'{}' is no valid value for the FRACTALIS_MODE "
"environment variable.".format(mode)) from e
import os
import fractalis
import pytest
from importlib import reload
class TestConfig:
......@@ -27,3 +28,8 @@ class TestConfig:
reload(fractalis)
assert not fractalis.app.config['DEBUG']
assert not fractalis.app.config['TESTING']
def test_config_when_unknown_mode(self):
os.environ['FRACTALIS_MODE'] = 'foobar'
with pytest.raises(KeyError):
reload(fractalis)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment