diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-06-01 15:36:17 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-06-01 16:21:46 +0800 |
commit | 59cba325d8132186d27aefa959d4bed730e4e68d (patch) | |
tree | 3407ccfc8696fde3572e7d9a5b0e8aa1918e9842 /result_collection_api/tests/unit/test_pod.py | |
parent | da342687570cd53f2bfb0e1d69db77b1ba664801 (diff) |
project-ize testAPI
JIRA: FUNCTEST-284
Change-Id: I219e934bb11f50de84df2aa0345ecc7885223491
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'result_collection_api/tests/unit/test_pod.py')
-rw-r--r-- | result_collection_api/tests/unit/test_pod.py | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/result_collection_api/tests/unit/test_pod.py b/result_collection_api/tests/unit/test_pod.py deleted file mode 100644 index 1a43c05..0000000 --- a/result_collection_api/tests/unit/test_pod.py +++ /dev/null @@ -1,81 +0,0 @@ -import unittest - -from test_base import TestBase -from resources.pod_models import PodCreateRequest, Pod, Pods -from common.constants import HTTP_OK, HTTP_BAD_REQUEST, \ - HTTP_FORBIDDEN, HTTP_NOT_FOUND - - -class TestPodBase(TestBase): - def setUp(self): - super(TestPodBase, self).setUp() - self.req_d = PodCreateRequest('zte-1', 'virtual', - 'zte pod 1', 'ci-pod') - self.req_e = PodCreateRequest('zte-2', 'metal', 'zte pod 2') - self.get_res = Pod - self.list_res = Pods - self.basePath = '/api/v1/pods' - - def assert_get_body(self, pod, req=None): - if not req: - req = self.req_d - self.assertEqual(pod.name, req.name) - self.assertEqual(pod.mode, req.mode) - self.assertEqual(pod.details, req.details) - self.assertEqual(pod.role, req.role) - self.assertIsNotNone(pod.creation_date) - self.assertIsNotNone(pod._id) - - -class TestPodCreate(TestPodBase): - def test_withoutBody(self): - (code, body) = self.create() - self.assertEqual(code, HTTP_BAD_REQUEST) - - def test_emptyName(self): - req_empty = PodCreateRequest('') - (code, body) = self.create(req_empty) - self.assertEqual(code, HTTP_BAD_REQUEST) - self.assertIn('name missing', body) - - def test_noneName(self): - req_none = PodCreateRequest(None) - (code, body) = self.create(req_none) - self.assertEqual(code, HTTP_BAD_REQUEST) - self.assertIn('name missing', body) - - def test_success(self): - code, body = self.create_d() - self.assertEqual(code, HTTP_OK) - self.assert_create_body(body) - - def test_alreadyExist(self): - self.create_d() - code, body = self.create_d() - self.assertEqual(code, HTTP_FORBIDDEN) - self.assertIn('already exists', body) - - -class TestPodGet(TestPodBase): - def test_notExist(self): - code, body = self.get('notExist') - self.assertEqual(code, HTTP_NOT_FOUND) - - def test_getOne(self): - self.create_d() - code, body = self.get(self.req_d.name) - self.assert_get_body(body) - - def test_list(self): - self.create_d() - self.create_e() - code, body = self.get() - self.assertEqual(len(body.pods), 2) - for pod in body.pods: - if self.req_d.name == pod.name: - self.assert_get_body(pod) - else: - self.assert_get_body(pod, self.req_e) - -if __name__ == '__main__': - unittest.main() |