|
|
|
@ -16,6 +16,20 @@ def test_env_braces(monkeypatch):
|
|
|
|
|
module.resolve_env_variables(config)
|
|
|
|
|
assert config == {'key': 'Hello foo'}
|
|
|
|
|
|
|
|
|
|
def test_env_multi(monkeypatch):
|
|
|
|
|
monkeypatch.setenv('MY_CUSTOM_VALUE', 'foo')
|
|
|
|
|
monkeypatch.setenv('MY_CUSTOM_VALUE2', 'bar')
|
|
|
|
|
config = {'key': 'Hello ${MY_CUSTOM_VALUE}${MY_CUSTOM_VALUE2}'}
|
|
|
|
|
module.resolve_env_variables(config)
|
|
|
|
|
assert config == {'key': 'Hello foobar'}
|
|
|
|
|
|
|
|
|
|
def test_env_escape(monkeypatch):
|
|
|
|
|
monkeypatch.setenv('MY_CUSTOM_VALUE', 'foo')
|
|
|
|
|
monkeypatch.setenv('MY_CUSTOM_VALUE2', 'bar')
|
|
|
|
|
config = {'key': r'Hello ${MY_CUSTOM_VALUE} \${MY_CUSTOM_VALUE}'}
|
|
|
|
|
module.resolve_env_variables(config)
|
|
|
|
|
assert config == {'key': r'Hello foo ${MY_CUSTOM_VALUE}'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_env_default_value(monkeypatch):
|
|
|
|
|
monkeypatch.delenv('MY_CUSTOM_VALUE', raising=False)
|
|
|
|
@ -41,6 +55,7 @@ def test_env_full(monkeypatch):
|
|
|
|
|
'anotherdict': {
|
|
|
|
|
'key': 'My ${MY_CUSTOM_VALUE} here',
|
|
|
|
|
'other': '${MY_CUSTOM_VALUE}',
|
|
|
|
|
'escaped': r'\${MY_CUSTOM_VALUE}',
|
|
|
|
|
'list': [
|
|
|
|
|
'/home/${MY_CUSTOM_VALUE}/.local',
|
|
|
|
|
'/var/log/',
|
|
|
|
@ -62,6 +77,7 @@ def test_env_full(monkeypatch):
|
|
|
|
|
'anotherdict': {
|
|
|
|
|
'key': 'My foo here',
|
|
|
|
|
'other': 'foo',
|
|
|
|
|
'escaped': '${MY_CUSTOM_VALUE}',
|
|
|
|
|
'list': ['/home/foo/.local', '/var/log/', '/home/bar/.config'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|