summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/opnfv_testapi/tests')
-rw-r--r--testapi/opnfv_testapi/tests/unit/common/test_config.py2
-rw-r--r--testapi/opnfv_testapi/tests/unit/executor.py14
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_project.py17
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_result.py39
4 files changed, 18 insertions, 54 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/common/test_config.py b/testapi/opnfv_testapi/tests/unit/common/test_config.py
index 6d160ce..8e4966f 100644
--- a/testapi/opnfv_testapi/tests/unit/common/test_config.py
+++ b/testapi/opnfv_testapi/tests/unit/common/test_config.py
@@ -11,7 +11,7 @@ def test_config_normal(mocker, config_normal):
assert CONF.mongo_url == 'mongodb://127.0.0.1:27017/'
assert CONF.mongo_dbname == 'test_results_collection'
assert CONF.api_port == 8000
- assert CONF.api_debug is True
+ assert CONF.api_debug is False
assert CONF.api_token_check is False
assert CONF.api_authenticate is True
assert CONF.ui_url == 'http://localhost:8000'
diff --git a/testapi/opnfv_testapi/tests/unit/executor.py b/testapi/opnfv_testapi/tests/unit/executor.py
index 743c076..d08782c 100644
--- a/testapi/opnfv_testapi/tests/unit/executor.py
+++ b/testapi/opnfv_testapi/tests/unit/executor.py
@@ -43,20 +43,6 @@ def mock_valid_lfid():
return _mock_valid_lfid
-def upload(excepted_status, excepted_response):
- def _upload(create_request):
- @functools.wraps(create_request)
- def wrap(self):
- request = create_request(self)
- status, body = self.upload(request)
- if excepted_status == httplib.OK:
- getattr(self, excepted_response)(body)
- else:
- self.assertIn(excepted_response, body)
- return wrap
- return _upload
-
-
def create(excepted_status, excepted_response):
def _create(create_request):
@functools.wraps(create_request)
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_project.py b/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
index cbd1a4e..884dd68 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
@@ -12,6 +12,7 @@ import urllib
from opnfv_testapi.common import message
from opnfv_testapi.models import project_models
+from opnfv_testapi.models import testcase_models as tcm
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit.handlers import test_base as base
@@ -23,6 +24,9 @@ class TestProjectBase(base.TestBase):
'qtip-ssh test')
self.req_e = project_models.ProjectCreateRequest('functest',
'functest test')
+ self.testcase_d = tcm.TestcaseCreateRequest.from_dict(
+ self.load_json('testcase_d'))
+ self.project = 'qtip'
self.get_res = project_models.Project
self.list_res = project_models.Projects
self.update_res = project_models.Project
@@ -150,6 +154,13 @@ class TestProjectUpdate(TestProjectBase):
return self.req_d, self.req_d.name
@executor.mock_valid_lfid()
+ @executor.update(httplib.UNAUTHORIZED, message.tied_with_resource())
+ def test_updateNotAllowed(self):
+ self.create_help('/api/v1/projects/%s/cases', self.testcase_d, self.req_d.name)
+ req = project_models.ProjectUpdateRequest('apex', 'apex test')
+ return req, self.req_d.name
+
+ @executor.mock_valid_lfid()
@executor.update(httplib.OK, '_assert_update')
def test_success(self):
req = project_models.ProjectUpdateRequest('apex', 'apex test')
@@ -178,6 +189,12 @@ class TestProjectDelete(TestProjectBase):
return 'notFound'
@executor.mock_valid_lfid()
+ @executor.delete(httplib.UNAUTHORIZED, message.tied_with_resource())
+ def test_deleteNotAllowed(self):
+ self.create_help('/api/v1/projects/%s/cases', self.testcase_d, self.req_d.name)
+ return self.req_d.name
+
+ @executor.mock_valid_lfid()
@executor.delete(httplib.OK, '_assert_delete')
def test_success(self):
return self.req_d.name
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
index f1f055e..c07d792 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
@@ -10,7 +10,6 @@ import copy
from datetime import datetime
from datetime import timedelta
import httplib
-import json
import urllib
from opnfv_testapi.common import message
@@ -46,22 +45,6 @@ class TestResultBase(base.TestBase):
_, res = self.create_d()
return res.href.split('/')[-1]
- def upload(self, req):
- if req and not isinstance(req, str) and hasattr(req, 'format'):
- req = req.format()
- res = self.fetch(self.basePath + '/upload',
- method='POST',
- body=json.dumps(req),
- headers=self.headers)
-
- return self._get_return(res, self.create_res)
-
-
-class TestResultUpload(TestResultBase):
- @executor.upload(httplib.BAD_REQUEST, message.key_error('file'))
- def test_filenotfind(self):
- return None
-
class TestResultCreate(TestResultBase):
@executor.create(httplib.BAD_REQUEST, message.no_body())
@@ -197,16 +180,6 @@ class TestResultGet(TestResultBase):
def test_queryLast(self):
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()
-
- @executor.query(httplib.OK, '_query_success', 1)
- def test_queryPrivate(self):
- self._create_private_data()
- return self._set_query(public='false')
-
@executor.query(httplib.OK, '_query_period_one', 1)
def test_combination(self):
return self._set_query('pod',
@@ -266,18 +239,6 @@ class TestResultGet(TestResultBase):
self.create(req)
return req
- def _create_public_data(self, **kwargs):
- req = copy.deepcopy(self.req_d)
- req.public = 'true'
- self.create(req)
- return req
-
- def _create_private_data(self, **kwargs):
- req = copy.deepcopy(self.req_d)
- req.public = 'false'
- self.create(req)
- return req
-
def _set_query(self, *args, **kwargs):
def get_value(arg):
if arg in ['pod', 'project', 'case']: