summaryrefslogtreecommitdiffstats
path: root/utils/test
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test')
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py
index f5026c957..1df31f36c 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py
@@ -11,6 +11,7 @@ from datetime import datetime
from datetime import timedelta
import httplib
import json
+import urllib
import unittest
from opnfv_testapi.common import message
@@ -268,29 +269,29 @@ class TestResultGet(TestResultBase):
@executor.query(httplib.BAD_REQUEST, message.must_int('period'))
def test_queryPeriodNotInt(self):
- return self._set_query('period=a')
+ return self._set_query(period='a')
@executor.query(httplib.OK, '_query_period_one', 1)
def test_queryPeriodSuccess(self):
- return self._set_query('period=5')
+ return self._set_query(period=5)
@executor.query(httplib.BAD_REQUEST, message.must_int('last'))
def test_queryLastNotInt(self):
- return self._set_query('last=a')
+ return self._set_query(last='a')
@executor.query(httplib.OK, '_query_last_one', 1)
def test_queryLast(self):
- return self._set_query('last=1')
+ return self._set_query(last=1)
@executor.query(httplib.OK, '_query_success', 4)
def test_queryPublic(self):
self._create_public_data()
- return self._set_query('')
+ return self._set_query()
@executor.query(httplib.OK, '_query_success', 1)
def test_queryPrivate(self):
self._create_private_data()
- return self._set_query('public=false')
+ return self._set_query(public='false')
@executor.query(httplib.OK, '_query_period_one', 1)
def test_combination(self):
@@ -303,12 +304,11 @@ class TestResultGet(TestResultBase):
'scenario',
'trust_indicator',
'criteria',
- 'period=5')
+ period=5)
@executor.query(httplib.OK, '_query_success', 0)
def test_notFound(self):
- return self._set_query('pod=notExistPod',
- 'project',
+ return self._set_query('project',
'case',
'version',
'installer',
@@ -316,7 +316,8 @@ class TestResultGet(TestResultBase):
'scenario',
'trust_indicator',
'criteria',
- 'period=1')
+ pod='notExistPod',
+ period=1)
@executor.query(httplib.OK, '_query_success', 1)
def test_filterErrorStartdate(self):
@@ -324,7 +325,7 @@ class TestResultGet(TestResultBase):
self._create_error_start_date('None')
self._create_error_start_date('null')
self._create_error_start_date('')
- return self._set_query('period=5')
+ return self._set_query(period=5)
def _query_success(self, body, number):
self.assertEqual(number, len(body.results))
@@ -363,18 +364,16 @@ class TestResultGet(TestResultBase):
self.create(req)
return req
- def _set_query(self, *args):
+ def _set_query(self, *args, **kwargs):
def get_value(arg):
return self.__getattribute__(arg) \
if arg != 'trust_indicator' else self.trust_indicator.current
- uri = ''
+ query = []
for arg in args:
- if arg:
- if '=' in arg:
- uri += arg + '&'
- else:
- uri += '{}={}&'.format(arg, get_value(arg))
- return uri[0: -1]
+ query.append((arg, get_value(arg)))
+ for k, v in kwargs.iteritems():
+ query.append((k, v))
+ return urllib.urlencode(query)
class TestResultUpdate(TestResultBase):