Skip to content

Commit

Permalink
Fix guilhermechapiewski#25 converting environment config to lowercase…
Browse files Browse the repository at this point in the history
…, the other parameters should be used as is for instance database password or configuration filename
  • Loading branch information
wandenberg committed Dec 26, 2014
1 parent b82f951 commit cd43bcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion simple_db_migrate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, config_file="simple-db-migrate.conf", environment=''):
super(FileConfig, self).__init__(inital_config=settings)

if environment:
prefix = environment + "_"
prefix = environment.lower() + "_"
for key in self._config.keys():
if key.startswith(prefix):
self.update(key[len(prefix):], self.get(key))
Expand Down
6 changes: 6 additions & 0 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ def test_it_should_use_configuration_by_environment(self):
self.assertEquals('migration_example_env1', config.get('database_name'))
self.assertEquals('root', config.get('database_user'))

def test_it_should_accept_environment_in_any_case(self):
config_path = os.path.abspath('sample.conf')
config = FileConfig(config_path, "EnV1")
self.assertEquals('migration_example_env1', config.get('database_name'))
self.assertEquals('root', config.get('database_user'))

def test_it_should_stop_execution_when_an_invalid_key_is_requested(self):
config_path = os.path.abspath('sample.conf')
config = FileConfig(config_path)
Expand Down

0 comments on commit cd43bcc

Please sign in to comment.