Code Review
/
releng.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
import from absolute path in TestAPI unit
[releng.git]
/
utils
/
test
/
testapi
/
opnfv_testapi
/
tests
/
unit
/
test_testcase.py
diff --git
a/utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py
b/utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py
index
c0494db
..
73c4819
100644
(file)
--- a/
utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py
+++ b/
utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py
@@
-7,12
+7,13
@@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import copy
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import copy
+import httplib
import unittest
import unittest
-from opnfv_testapi.common import
constants
+from opnfv_testapi.common import
message
from opnfv_testapi.resources import project_models
from opnfv_testapi.resources import testcase_models
from opnfv_testapi.resources import project_models
from opnfv_testapi.resources import testcase_models
-import test_base as base
+
from opnfv_testapi.tests.unit
import test_base as base
class TestCaseBase(base.TestBase):
class TestCaseBase(base.TestBase):
@@
-79,46
+80,46
@@
class TestCaseBase(base.TestBase):
class TestCaseCreate(TestCaseBase):
def test_noBody(self):
(code, body) = self.create(None, 'vping')
class TestCaseCreate(TestCaseBase):
def test_noBody(self):
(code, body) = self.create(None, 'vping')
- self.assertEqual(code,
constants.HTTP_
BAD_REQUEST)
+ self.assertEqual(code,
httplib.
BAD_REQUEST)
def test_noProject(self):
code, body = self.create(self.req_d, 'noProject')
def test_noProject(self):
code, body = self.create(self.req_d, 'noProject')
- self.assertEqual(code,
constants.HTTP_
FORBIDDEN)
- self.assertIn(
'Could not find project'
, body)
+ self.assertEqual(code,
httplib.
FORBIDDEN)
+ self.assertIn(
message.not_found_base
, body)
def test_emptyName(self):
req_empty = testcase_models.TestcaseCreateRequest('')
(code, body) = self.create(req_empty, self.project)
def test_emptyName(self):
req_empty = testcase_models.TestcaseCreateRequest('')
(code, body) = self.create(req_empty, self.project)
- self.assertEqual(code,
constants.HTTP_
BAD_REQUEST)
- self.assertIn(
'name missing'
, body)
+ self.assertEqual(code,
httplib.
BAD_REQUEST)
+ self.assertIn(
message.missing('name')
, body)
def test_noneName(self):
req_none = testcase_models.TestcaseCreateRequest(None)
(code, body) = self.create(req_none, self.project)
def test_noneName(self):
req_none = testcase_models.TestcaseCreateRequest(None)
(code, body) = self.create(req_none, self.project)
- self.assertEqual(code,
constants.HTTP_
BAD_REQUEST)
- self.assertIn(
'name missing'
, body)
+ self.assertEqual(code,
httplib.
BAD_REQUEST)
+ self.assertIn(
message.missing('name')
, body)
def test_success(self):
code, body = self.create_d()
def test_success(self):
code, body = self.create_d()
- self.assertEqual(code,
constants.HTTP_
OK)
+ self.assertEqual(code,
httplib.
OK)
self.assert_create_body(body, None, self.project)
def test_alreadyExist(self):
self.create_d()
code, body = self.create_d()
self.assert_create_body(body, None, self.project)
def test_alreadyExist(self):
self.create_d()
code, body = self.create_d()
- self.assertEqual(code,
constants.HTTP_
FORBIDDEN)
- self.assertIn(
'already exists'
, body)
+ self.assertEqual(code,
httplib.
FORBIDDEN)
+ self.assertIn(
message.exist_base
, body)
class TestCaseGet(TestCaseBase):
def test_notExist(self):
code, body = self.get('notExist')
class TestCaseGet(TestCaseBase):
def test_notExist(self):
code, body = self.get('notExist')
- self.assertEqual(code,
constants.HTTP_
NOT_FOUND)
+ self.assertEqual(code,
httplib.
NOT_FOUND)
def test_getOne(self):
self.create_d()
code, body = self.get(self.req_d.name)
def test_getOne(self):
self.create_d()
code, body = self.get(self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
OK)
+ self.assertEqual(code,
httplib.
OK)
self.assert_body(body)
def test_list(self):
self.assert_body(body)
def test_list(self):
@@
-135,24
+136,24
@@
class TestCaseGet(TestCaseBase):
class TestCaseUpdate(TestCaseBase):
def test_noBody(self):
code, _ = self.update(case='noBody')
class TestCaseUpdate(TestCaseBase):
def test_noBody(self):
code, _ = self.update(case='noBody')
- self.assertEqual(code,
constants.HTTP_
BAD_REQUEST)
+ self.assertEqual(code,
httplib.
BAD_REQUEST)
def test_notFound(self):
code, _ = self.update(self.update_e, 'notFound')
def test_notFound(self):
code, _ = self.update(self.update_e, 'notFound')
- self.assertEqual(code,
constants.HTTP_
NOT_FOUND)
+ self.assertEqual(code,
httplib.
NOT_FOUND)
def test_newNameExist(self):
self.create_d()
self.create_e()
code, body = self.update(self.update_e, self.req_d.name)
def test_newNameExist(self):
self.create_d()
self.create_e()
code, body = self.update(self.update_e, self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
FORBIDDEN)
- self.assertIn(
"already exists"
, body)
+ self.assertEqual(code,
httplib.
FORBIDDEN)
+ self.assertIn(
message.exist_base
, body)
def test_noUpdate(self):
self.create_d()
code, body = self.update(self.update_d, self.req_d.name)
def test_noUpdate(self):
self.create_d()
code, body = self.update(self.update_d, self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
FORBIDDEN)
- self.assertIn(
"Nothing to update"
, body)
+ self.assertEqual(code,
httplib.
FORBIDDEN)
+ self.assertIn(
message.no_update()
, body)
def test_success(self):
self.create_d()
def test_success(self):
self.create_d()
@@
-160,7
+161,7
@@
class TestCaseUpdate(TestCaseBase):
_id = body._id
code, body = self.update(self.update_e, self.req_d.name)
_id = body._id
code, body = self.update(self.update_e, self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
OK)
+ self.assertEqual(code,
httplib.
OK)
self.assertEqual(_id, body._id)
self.assert_update_body(self.req_d, body, self.update_e)
self.assertEqual(_id, body._id)
self.assert_update_body(self.req_d, body, self.update_e)
@@
-173,22
+174,22
@@
class TestCaseUpdate(TestCaseBase):
update = copy.deepcopy(self.update_d)
update.description = {'2. change': 'dollar change'}
code, body = self.update(update, self.req_d.name)
update = copy.deepcopy(self.update_d)
update.description = {'2. change': 'dollar change'}
code, body = self.update(update, self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
OK)
+ self.assertEqual(code,
httplib.
OK)
class TestCaseDelete(TestCaseBase):
def test_notFound(self):
code, body = self.delete('notFound')
class TestCaseDelete(TestCaseBase):
def test_notFound(self):
code, body = self.delete('notFound')
- self.assertEqual(code,
constants.HTTP_
NOT_FOUND)
+ self.assertEqual(code,
httplib.
NOT_FOUND)
def test_success(self):
self.create_d()
code, body = self.delete(self.req_d.name)
def test_success(self):
self.create_d()
code, body = self.delete(self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
OK)
+ self.assertEqual(code,
httplib.
OK)
self.assertEqual(body, '')
code, body = self.get(self.req_d.name)
self.assertEqual(body, '')
code, body = self.get(self.req_d.name)
- self.assertEqual(code,
constants.HTTP_
NOT_FOUND)
+ self.assertEqual(code,
httplib.
NOT_FOUND)
if __name__ == '__main__':
if __name__ == '__main__':