summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi
diff options
context:
space:
mode:
authorJose Lausuch <jose.lausuch@ericsson.com>2017-03-23 09:12:08 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-23 09:12:08 +0000
commit79aca1e76a70fa25a6e590bb330a95190a64821e (patch)
tree13c51fb1774d7d15f5eb495a85ce5d7b06971ce9 /utils/test/testapi
parent05d85f74c75f14e061316835329173cc88e9bb02 (diff)
parent6d4fca821c3bc23369d2295062b01f1543c10550 (diff)
Merge "start TestAPI in venv with no config-file"
Diffstat (limited to 'utils/test/testapi')
-rw-r--r--utils/test/testapi/opnfv_testapi/common/config.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/utils/test/testapi/opnfv_testapi/common/config.py b/utils/test/testapi/opnfv_testapi/common/config.py
index 105d4fabf..362fca640 100644
--- a/utils/test/testapi/opnfv_testapi/common/config.py
+++ b/utils/test/testapi/opnfv_testapi/common/config.py
@@ -30,7 +30,7 @@ class APIConfig(object):
"""
def __init__(self):
- self._default_config_location = "/etc/opnfv_testapi/config.ini"
+ self._set_default_config()
self.mongo_url = None
self.mongo_dbname = None
self.api_port = None
@@ -39,6 +39,11 @@ class APIConfig(object):
self._parser = None
self.swagger_base_url = None
+ def _set_default_config(self):
+ venv = os.getenv('VIRTUAL_ENV')
+ self._default_config = os.path.join('/' if not venv else venv,
+ 'etc/opnfv_testapi/config.ini')
+
def _get_parameter(self, section, param):
try:
return self._parser.get(section, param)
@@ -66,7 +71,7 @@ class APIConfig(object):
obj = APIConfig()
if config_location is None:
- config_location = obj._default_config_location
+ config_location = obj._default_config
if not os.path.exists(config_location):
raise ParseError("%s not found" % config_location)