summaryrefslogtreecommitdiffstats
path: root/utils/test
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test')
-rwxr-xr-xutils/test/testapi/install.sh3
-rw-r--r--utils/test/testapi/opnfv_testapi/common/config.py9
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/handlers.py6
-rwxr-xr-xutils/test/testapi/run_test.sh14
-rw-r--r--utils/test/testapi/test-requirements.txt5
5 files changed, 19 insertions, 18 deletions
diff --git a/utils/test/testapi/install.sh b/utils/test/testapi/install.sh
index c55691aed..bf828b580 100755
--- a/utils/test/testapi/install.sh
+++ b/utils/test/testapi/install.sh
@@ -26,3 +26,6 @@ fi
cp -fr 3rd_party/static opnfv_testapi/tornado_swagger
python setup.py install
rm -fr opnfv_testapi/tornado_swagger/static
+if [ ! -z "$VIRTUAL_ENV" ]; then
+ sed -i -e 's#etc/opnfv_testapi =#/etc/opnfv_testapi =#g' setup.cfg
+fi \ No newline at end of file
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)
diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py
index 8255b526a..15096468c 100644
--- a/utils/test/testapi/opnfv_testapi/resources/handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py
@@ -92,8 +92,6 @@ class GenericApiHandler(web.RequestHandler):
raise gen.Return(ret)
return wrapper
- @web.asynchronous
- @gen.coroutine
@authenticate
def _create(self, miss_checks, db_checks, **kwargs):
"""
@@ -158,8 +156,6 @@ class GenericApiHandler(web.RequestHandler):
.format(query, self.table))
self.finish_request(self.format_data(data))
- @web.asynchronous
- @gen.coroutine
@authenticate
def _delete(self, query):
data = yield self._eval_db_find_one(query)
@@ -171,8 +167,6 @@ class GenericApiHandler(web.RequestHandler):
yield self._eval_db(self.table, 'remove', query)
self.finish_request()
- @web.asynchronous
- @gen.coroutine
@authenticate
def _update(self, query, db_keys):
if self.json_args is None:
diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh
index 4efc7af3b..1e05dd6ba 100755
--- a/utils/test/testapi/run_test.sh
+++ b/utils/test/testapi/run_test.sh
@@ -8,15 +8,17 @@ SCRIPTDIR=`dirname $0`
echo "Running unit tests..."
# Creating virtual environment
-virtualenv $SCRIPTDIR/testapi_venv
-source $SCRIPTDIR/testapi_venv/bin/activate
+if [ ! -z $VIRTUAL_ENV ]; then
+ venv=$VIRTUAL_ENV
+else
+ venv=$SCRIPTDIR/.venv
+ virtualenv $venv
+fi
+source $venv/bin/activate
# Install requirements
pip install -r $SCRIPTDIR/requirements.txt
-pip install coverage
-pip install nose>=1.3.1
-pip install pytest
-pip install mock
+pip install -r $SCRIPTDIR/test-requirements.txt
find . -type f -name "*.pyc" -delete
diff --git a/utils/test/testapi/test-requirements.txt b/utils/test/testapi/test-requirements.txt
index 4633ad637..645687b14 100644
--- a/utils/test/testapi/test-requirements.txt
+++ b/utils/test/testapi/test-requirements.txt
@@ -2,10 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-tox
mock
pytest
-pytest-cov
coverage
-pykwalify
-pip_check_reqs
+nose>=1.3.1