Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for expanding environment variables in configuration files. #378

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/unit/resources/environment_variable.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=${ENVIRONMENT_VARIABLE}
8 changes: 8 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ def test_get_properties(self):
'd\\=': '4', 'e\\:': '5', 'f': '==6',
'g': '= 7', 'h': ':8', 'i': '9', 'j': '${ENVIRONMENT_VARIABLE}'})

@patch('prestoadmin.config.os.path.expandvars', return_value='environment_variable_value')
def test_expending_environment_variable(self, environment_variables):
config_file = os.path.join(DIR, 'resources', 'environment_variable.properties')
conf = config.get_conf_from_properties_file(config_file)
self.assertTrue(environment_variables.called)
self.assertEqual({'a': 'environment_variable_value'}, conf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have an real test that is using actual environment variable, to see the configuration with expanded environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply. I will work on this as well as automation failures.



@patch('__builtin__.open')
def test_get_properties_ignores_whitespace(self, open_mock):
file_manager = open_mock.return_value.__enter__.return_value
Expand Down