diff --git a/hbp_nrp_virtual_coach/pynrp/config.py b/hbp_nrp_virtual_coach/pynrp/config.py index a363bb3561cfd4053b8afaed933a59db316e90ca..5e1b146fa6be036e4ed0c9de7ce5836ad9494996 100644 --- a/hbp_nrp_virtual_coach/pynrp/config.py +++ b/hbp_nrp_virtual_coach/pynrp/config.py @@ -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): """ diff --git a/hbp_nrp_virtual_coach/pynrp/tests/test_config.py b/hbp_nrp_virtual_coach/pynrp/tests/test_config.py index 40d9cd77e1415243ad9afd97c06cc02989a80aac..5c8cf8cfe9837ff3992ee53871f942953debc0f6 100644 --- a/hbp_nrp_virtual_coach/pynrp/tests/test_config.py +++ b/hbp_nrp_virtual_coach/pynrp/tests/test_config.py @@ -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