X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ftest%2Ftestapi%2Fopnfv_testapi%2Ftests%2Funit%2Ftest_testcase.py;h=73c4819866b4b5b8eeb1ab170a26b9b83df20695;hb=c12d3a2c298724bf5186c627967430f32a7e33ba;hp=c0494db5d32330992ee55027194803f47d809763;hpb=9193d235dc58e25639f093adab9fb903e6068456;p=releng.git 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 c0494db5d..73c481986 100644 --- 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 +import httplib 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 -import test_base as base +from opnfv_testapi.tests.unit import test_base as base 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') - 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.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) - 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) - 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() - 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.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') - 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,24 +136,24 @@ 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.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) - 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() @@ -160,7 +161,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 +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) - 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__':