replace self-defined http codes with standard definitions
[releng.git] / utils / test / testapi / opnfv_testapi / tests / unit / test_testcase.py
index c0494db..ec44fca 100644 (file)
@@ -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__':