Skip to content
Snippets Groups Projects
Commit 7a29c79a authored by Viktor Vorobev's avatar Viktor Vorobev
Browse files

Merged in NRRPLT-8901 (pull request #47)

[NRRPLT-8901] Remove the trailing `/` in the address

* [NRRPLT-8901] Remove the trailing `/` in the address

* [NRRPLT-8901] Add test for trailing slash

* [NRRPLT-8901] Fixes and updates


Approved-by: Ugo Albanese
parent d3e98f60
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,9 @@ class Config(dict):
# initialize the parent dictionary, required by pylint
dict.__init__(self)
# remove trailing slash in the environment url
url = environment[:-1] if environment.endswith('/') else environment
# ensure the config.json file exists and is readable by our user
logger.info('Loading configuration file config.json')
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.json')
......@@ -90,7 +93,7 @@ class Config(dict):
# convenience, prepend the proxy url to all proxy services, we cannot do this
# for the simulation services because they are backend/experiment id specific
for k, v in self['proxy-services'].items():
self['proxy-services'][k] = '{}/proxy/{}'.format(environment, v)
self['proxy-services'][k] = '{}/proxy/{}'.format(url, v)
def __validate(self, key, values):
"""
......
......@@ -65,6 +65,9 @@ class TestConfig(unittest.TestCase):
for k, v in config['proxy-services'].items():
self.assertEqual(v, '%s/proxy/%s' % ('localhost', self._conf['proxy-services'][k]))
def test_trailing_slash(self):
self.assertEqual(Config('localhost:8080'), Config('localhost:8080/'))
@patch('pynrp.config.json.load')
def test_validation_missing_key(self, mock_load):
# missing section
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment