summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/tests
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-04-05 16:23:03 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-04-06 16:55:21 +0800
commit0620b2cbb21714c1a5e485186c46c2c24485ef37 (patch)
tree48fae29c4a2827d51ce6bc418910194b54d35f5c /testapi/opnfv_testapi/tests
parentdbdb452b2761a630ec8574b22553ac5531611201 (diff)
unify error message in TestAPI
Change-Id: I994feb7bf340c9e48bebe9fdf3dc3a76bc254652 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/tests')
-rw-r--r--testapi/opnfv_testapi/tests/unit/test_pod.py7
-rw-r--r--testapi/opnfv_testapi/tests/unit/test_project.py11
-rw-r--r--testapi/opnfv_testapi/tests/unit/test_result.py15
-rw-r--r--testapi/opnfv_testapi/tests/unit/test_scenario.py7
-rw-r--r--testapi/opnfv_testapi/tests/unit/test_testcase.py13
-rw-r--r--testapi/opnfv_testapi/tests/unit/test_token.py13
6 files changed, 36 insertions, 30 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/test_pod.py b/testapi/opnfv_testapi/tests/unit/test_pod.py
index cec90d8..cae86e8 100644
--- a/testapi/opnfv_testapi/tests/unit/test_pod.py
+++ b/testapi/opnfv_testapi/tests/unit/test_pod.py
@@ -9,6 +9,7 @@
import httplib
import unittest
+from opnfv_testapi.common import message
from opnfv_testapi.resources import pod_models
import test_base as base
@@ -43,13 +44,13 @@ class TestPodCreate(TestPodBase):
req_empty = pod_models.PodCreateRequest('')
(code, body) = self.create(req_empty)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_noneName(self):
req_none = pod_models.PodCreateRequest(None)
(code, body) = self.create(req_none)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_success(self):
code, body = self.create_d()
@@ -60,7 +61,7 @@ class TestPodCreate(TestPodBase):
self.create_d()
code, body = self.create_d()
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('already exists', body)
+ self.assertIn(message.exist_base, body)
class TestPodGet(TestPodBase):
diff --git a/testapi/opnfv_testapi/tests/unit/test_project.py b/testapi/opnfv_testapi/tests/unit/test_project.py
index 75b2d52..74cefd7 100644
--- a/testapi/opnfv_testapi/tests/unit/test_project.py
+++ b/testapi/opnfv_testapi/tests/unit/test_project.py
@@ -9,6 +9,7 @@
import httplib
import unittest
+from opnfv_testapi.common import message
from opnfv_testapi.resources import project_models
import test_base as base
@@ -43,13 +44,13 @@ class TestProjectCreate(TestProjectBase):
req_empty = project_models.ProjectCreateRequest('')
(code, body) = self.create(req_empty)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_noneName(self):
req_none = project_models.ProjectCreateRequest(None)
(code, body) = self.create(req_none)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_success(self):
(code, body) = self.create_d()
@@ -60,7 +61,7 @@ class TestProjectCreate(TestProjectBase):
self.create_d()
(code, body) = self.create_d()
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('already exists', body)
+ self.assertIn(message.exist_base, body)
class TestProjectGet(TestProjectBase):
@@ -99,13 +100,13 @@ class TestProjectUpdate(TestProjectBase):
self.create_e()
code, body = self.update(self.req_e, self.req_d.name)
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn("already exists", body)
+ self.assertIn(message.exist_base, body)
def test_noUpdate(self):
self.create_d()
code, body = self.update(self.req_d, self.req_d.name)
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn("Nothing to update", body)
+ self.assertIn(message.no_update(), body)
def test_success(self):
self.create_d()
diff --git a/testapi/opnfv_testapi/tests/unit/test_result.py b/testapi/opnfv_testapi/tests/unit/test_result.py
index 05220f1..ae78237 100644
--- a/testapi/opnfv_testapi/tests/unit/test_result.py
+++ b/testapi/opnfv_testapi/tests/unit/test_result.py
@@ -11,6 +11,7 @@ from datetime import datetime, timedelta
import httplib
import unittest
+from opnfv_testapi.common import message
from opnfv_testapi.resources import pod_models
from opnfv_testapi.resources import project_models
from opnfv_testapi.resources import result_models
@@ -135,49 +136,49 @@ class TestResultCreate(TestResultBase):
def test_nobody(self):
(code, body) = self.create(None)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('no body', body)
+ self.assertIn(message.no_body(), body)
def test_podNotProvided(self):
req = self.req_d
req.pod_name = None
(code, body) = self.create(req)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('pod_name missing', body)
+ self.assertIn(message.missing('pod_name'), body)
def test_projectNotProvided(self):
req = self.req_d
req.project_name = None
(code, body) = self.create(req)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('project_name missing', body)
+ self.assertIn(message.missing('project_name'), body)
def test_testcaseNotProvided(self):
req = self.req_d
req.case_name = None
(code, body) = self.create(req)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('case_name missing', body)
+ self.assertIn(message.missing('case_name'), body)
def test_noPod(self):
req = self.req_d
req.pod_name = 'notExistPod'
(code, body) = self.create(req)
self.assertEqual(code, httplib.NOT_FOUND)
- self.assertIn('Could not find pod', body)
+ self.assertIn(message.not_found_base, body)
def test_noProject(self):
req = self.req_d
req.project_name = 'notExistProject'
(code, body) = self.create(req)
self.assertEqual(code, httplib.NOT_FOUND)
- self.assertIn('Could not find project', body)
+ self.assertIn(message.not_found_base, body)
def test_noTestcase(self):
req = self.req_d
req.case_name = 'notExistTestcase'
(code, body) = self.create(req)
self.assertEqual(code, httplib.NOT_FOUND)
- self.assertIn('Could not find testcase', body)
+ self.assertIn(message.not_found_base, body)
def test_success(self):
(code, body) = self.create_d()
diff --git a/testapi/opnfv_testapi/tests/unit/test_scenario.py b/testapi/opnfv_testapi/tests/unit/test_scenario.py
index ab2c34b..f2291a5 100644
--- a/testapi/opnfv_testapi/tests/unit/test_scenario.py
+++ b/testapi/opnfv_testapi/tests/unit/test_scenario.py
@@ -5,6 +5,7 @@ import httplib
import json
import os
+from opnfv_testapi.common import message
import opnfv_testapi.resources.scenario_models as models
import test_base as base
@@ -66,13 +67,13 @@ class TestScenarioCreate(TestScenarioBase):
req_empty = models.ScenarioCreateRequest('')
(code, body) = self.create(req_empty)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_noneName(self):
req_none = models.ScenarioCreateRequest(None)
(code, body) = self.create(req_none)
self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_success(self):
(code, body) = self.create_d()
@@ -83,7 +84,7 @@ class TestScenarioCreate(TestScenarioBase):
self.create_d()
(code, body) = self.create_d()
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('already exists', body)
+ self.assertIn(message.exist_base, body)
class TestScenarioGet(TestScenarioBase):
diff --git a/testapi/opnfv_testapi/tests/unit/test_testcase.py b/testapi/opnfv_testapi/tests/unit/test_testcase.py
index ec44fca..62d0fa0 100644
--- a/testapi/opnfv_testapi/tests/unit/test_testcase.py
+++ b/testapi/opnfv_testapi/tests/unit/test_testcase.py
@@ -10,6 +10,7 @@ import copy
import httplib
import unittest
+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
@@ -84,19 +85,19 @@ class TestCaseCreate(TestCaseBase):
def test_noProject(self):
code, body = self.create(self.req_d, 'noProject')
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('Could not find project', body)
+ 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, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ 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, httplib.BAD_REQUEST)
- self.assertIn('name missing', body)
+ self.assertIn(message.missing('name'), body)
def test_success(self):
code, body = self.create_d()
@@ -107,7 +108,7 @@ class TestCaseCreate(TestCaseBase):
self.create_d()
code, body = self.create_d()
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('already exists', body)
+ self.assertIn(message.exist_base, body)
class TestCaseGet(TestCaseBase):
@@ -146,13 +147,13 @@ class TestCaseUpdate(TestCaseBase):
self.create_e()
code, body = self.update(self.update_e, self.req_d.name)
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn("already exists", body)
+ 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, httplib.FORBIDDEN)
- self.assertIn("Nothing to update", body)
+ self.assertIn(message.no_update(), body)
def test_success(self):
self.create_d()
diff --git a/testapi/opnfv_testapi/tests/unit/test_token.py b/testapi/opnfv_testapi/tests/unit/test_token.py
index 9cc52a2..ed3eda0 100644
--- a/testapi/opnfv_testapi/tests/unit/test_token.py
+++ b/testapi/opnfv_testapi/tests/unit/test_token.py
@@ -9,6 +9,7 @@ import unittest
from tornado import web
import fake_pymongo
+from opnfv_testapi.common import message
from opnfv_testapi.resources import project_models
from opnfv_testapi.router import url_mappings
import test_base as base
@@ -35,13 +36,13 @@ class TestTokenCreateProject(TestToken):
self.headers['X-Auth-Token'] = '1234'
code, body = self.create_d()
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('Invalid Token.', body)
+ self.assertIn(message.invalid_token(), body)
def test_projectCreateTokenUnauthorized(self):
self.headers.pop('X-Auth-Token')
code, body = self.create_d()
self.assertEqual(code, httplib.UNAUTHORIZED)
- self.assertIn('No Authentication Header.', body)
+ self.assertIn(message.unauthorized(), body)
def test_projectCreateTokenSuccess(self):
self.headers['X-Auth-Token'] = '12345'
@@ -62,7 +63,7 @@ class TestTokenDeleteProject(TestToken):
self.headers['X-Auth-Token'] = '1234'
code, body = self.delete(self.req_d.name)
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('Invalid Token.', body)
+ self.assertIn(message.invalid_token(), body)
def test_projectDeleteTokenUnauthorized(self):
self.headers['X-Auth-Token'] = '12345'
@@ -70,7 +71,7 @@ class TestTokenDeleteProject(TestToken):
self.headers.pop('X-Auth-Token')
code, body = self.delete(self.req_d.name)
self.assertEqual(code, httplib.UNAUTHORIZED)
- self.assertIn('No Authentication Header.', body)
+ self.assertIn(message.unauthorized(), body)
def test_projectDeleteTokenSuccess(self):
self.headers['X-Auth-Token'] = '12345'
@@ -94,7 +95,7 @@ class TestTokenUpdateProject(TestToken):
req = project_models.ProjectUpdateRequest('newName', 'new description')
code, body = self.update(req, self.req_d.name)
self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn('Invalid Token.', body)
+ self.assertIn(message.invalid_token(), body)
def test_projectUpdateTokenUnauthorized(self):
self.headers['X-Auth-Token'] = '12345'
@@ -104,7 +105,7 @@ class TestTokenUpdateProject(TestToken):
req = project_models.ProjectUpdateRequest('newName', 'new description')
code, body = self.update(req, self.req_d.name)
self.assertEqual(code, httplib.UNAUTHORIZED)
- self.assertIn('No Authentication Header.', body)
+ self.assertIn(message.unauthorized(), body)
def test_projectUpdateTokenSuccess(self):
self.headers['X-Auth-Token'] = '12345'