Merge "xci: Pass parameters to downstream jobs"
authorFatih Degirmenci <fatih.degirmenci@ericsson.com>
Thu, 23 Mar 2017 09:19:58 +0000 (09:19 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Thu, 23 Mar 2017 09:19:58 +0000 (09:19 +0000)
utils/test/testapi/install.sh
utils/test/testapi/opnfv_testapi/common/config.py
utils/test/testapi/opnfv_testapi/resources/handlers.py
utils/test/testapi/run_test.sh
utils/test/testapi/test-requirements.txt

index c55691a..bf828b5 100755 (executable)
@@ -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
index 105d4fa..362fca6 100644 (file)
@@ -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)
index 8255b52..1509646 100644 (file)
@@ -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:
index 4efc7af..1e05dd6 100755 (executable)
@@ -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
 
index 4633ad6..645687b 100644 (file)
@@ -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