diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-03-30 14:01:30 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-03-30 14:01:30 +0800 |
commit | 87393f4eba3b68f9598c02dcbe1f06f2afdd400c (patch) | |
tree | d38571be07983f75fe36d8b92ca84c470b65a176 /testapi/opnfv_testapi/tests/unit/test_testcase.py | |
parent | bc563719888542de948e3145b22d944dc38f783c (diff) |
replace self-defined http codes with standard definitions
Change-Id: I3045dc690e0bc1186f5c548cb533462dd03130d9
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/tests/unit/test_testcase.py')
-rw-r--r-- | testapi/opnfv_testapi/tests/unit/test_testcase.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/test_testcase.py b/testapi/opnfv_testapi/tests/unit/test_testcase.py index c0494db..ec44fca 100644 --- a/testapi/opnfv_testapi/tests/unit/test_testcase.py +++ b/testapi/opnfv_testapi/tests/unit/test_testcase.py @@ -7,9 +7,9 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## import copy +import httplib import unittest -from opnfv_testapi.common import constants from opnfv_testapi.resources import project_models from opnfv_testapi.resources import testcase_models import test_base as base @@ -79,46 +79,46 @@ class TestCaseBase(base.TestBase): 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') - self.assertEqual(code, constants.HTTP_FORBIDDEN) + self.assertEqual(code, httplib.FORBIDDEN) self.assertIn('Could not find project', body) 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.assertEqual(code, httplib.BAD_REQUEST) self.assertIn('name missing', body) 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.assertEqual(code, httplib.BAD_REQUEST) self.assertIn('name missing', body) 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.assertEqual(code, constants.HTTP_FORBIDDEN) + self.assertEqual(code, httplib.FORBIDDEN) self.assertIn('already exists', body) 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) - self.assertEqual(code, constants.HTTP_OK) + self.assertEqual(code, httplib.OK) self.assert_body(body) def test_list(self): @@ -135,23 +135,23 @@ class TestCaseGet(TestCaseBase): 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') - 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) - self.assertEqual(code, constants.HTTP_FORBIDDEN) + self.assertEqual(code, httplib.FORBIDDEN) self.assertIn("already exists", body) 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.assertEqual(code, httplib.FORBIDDEN) self.assertIn("Nothing to update", body) def test_success(self): @@ -160,7 +160,7 @@ class TestCaseUpdate(TestCaseBase): _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) @@ -173,22 +173,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) - self.assertEqual(code, constants.HTTP_OK) + self.assertEqual(code, httplib.OK) 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) - self.assertEqual(code, constants.HTTP_OK) + self.assertEqual(code, httplib.OK) 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__': |