summaryrefslogtreecommitdiffstats
path: root/utils/test/result_collection_api/tests
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-05-26 06:39:07 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-05-26 06:39:07 +0000
commit2377f84d9142dad19bfabc795d3a5a73e3c67533 (patch)
tree80ca788cb1dfe5a6241a102c61c8eea26cd4d9d7 /utils/test/result_collection_api/tests
parent3942c39c0b7b460a40571b70b5647bf147b298b3 (diff)
parent119faa49c41ab093aaa9767e906b448198e5c6c4 (diff)
Merge "attach version number to url in testAPI"
Diffstat (limited to 'utils/test/result_collection_api/tests')
-rw-r--r--utils/test/result_collection_api/tests/unit/test_base.py25
-rw-r--r--utils/test/result_collection_api/tests/unit/test_dashboard.py6
-rw-r--r--utils/test/result_collection_api/tests/unit/test_pod.py12
-rw-r--r--utils/test/result_collection_api/tests/unit/test_project.py2
-rw-r--r--utils/test/result_collection_api/tests/unit/test_result.py10
-rw-r--r--utils/test/result_collection_api/tests/unit/test_testcase.py4
-rw-r--r--utils/test/result_collection_api/tests/unit/test_version.py19
7 files changed, 43 insertions, 35 deletions
diff --git a/utils/test/result_collection_api/tests/unit/test_base.py b/utils/test/result_collection_api/tests/unit/test_base.py
index a06cba9fb..99b1de286 100644
--- a/utils/test/result_collection_api/tests/unit/test_base.py
+++ b/utils/test/result_collection_api/tests/unit/test_base.py
@@ -25,19 +25,18 @@ class TestBase(AsyncHTTPTestCase):
def get_app(self):
return Application(
[
- (r"/version", VersionHandler),
- (r"/pods", PodHandler),
- (r"/pods/([^/]+)", PodHandler),
- (r"/projects", ProjectHandler),
- (r"/projects/([^/]+)", ProjectHandler),
- (r"/projects/([^/]+)/cases", TestcaseHandler),
- (r"/projects/([^/]+)/cases/([^/]+)", TestcaseHandler),
- (r"/results", TestResultsHandler),
- (r"/results([^/]*)", TestResultsHandler),
- (r"/results/([^/]*)", TestResultsHandler),
- (r"/dashboard", DashboardHandler),
- (r"/dashboard([^/]*)", DashboardHandler),
- (r"/dashboard/([^/]*)", DashboardHandler),
+ (r"/versions", VersionHandler),
+ (r"/api/v1/pods", PodHandler),
+ (r"/api/v1/pods/([^/]+)", PodHandler),
+ (r"/api/v1/projects", ProjectHandler),
+ (r"/api/v1/projects/([^/]+)", ProjectHandler),
+ (r"/api/v1/projects/([^/]+)/cases", TestcaseHandler),
+ (r"/api/v1/projects/([^/]+)/cases/([^/]+)", TestcaseHandler),
+ (r"/api/v1/results", TestResultsHandler),
+ (r"/api/v1/results([^/]*)", TestResultsHandler),
+ (r"/api/v1/results/([^/]*)", TestResultsHandler),
+ (r"/dashboard/v1/results", DashboardHandler),
+ (r"/dashboard/v1/results([^/]*)", DashboardHandler),
],
db=fake_pymongo,
debug=True,
diff --git a/utils/test/result_collection_api/tests/unit/test_dashboard.py b/utils/test/result_collection_api/tests/unit/test_dashboard.py
index 1e0d22b91..5c3f92492 100644
--- a/utils/test/result_collection_api/tests/unit/test_dashboard.py
+++ b/utils/test/result_collection_api/tests/unit/test_dashboard.py
@@ -9,9 +9,9 @@ __author__ = '__serena__'
class TestDashboardBase(TestResultBase):
def setUp(self):
super(TestDashboardBase, self).setUp()
- self.basePath = '/dashboard'
- self.create_help('/results', self.req_d)
- self.create_help('/results', self.req_d)
+ self.basePath = '/dashboard/v1/results'
+ self.create_help('/api/v1/results', self.req_d)
+ self.create_help('/api/v1/results', self.req_d)
self.list_res = None
diff --git a/utils/test/result_collection_api/tests/unit/test_pod.py b/utils/test/result_collection_api/tests/unit/test_pod.py
index b6adc25ec..d7f4c3a63 100644
--- a/utils/test/result_collection_api/tests/unit/test_pod.py
+++ b/utils/test/result_collection_api/tests/unit/test_pod.py
@@ -9,11 +9,12 @@ from common.constants import HTTP_OK, HTTP_BAD_REQUEST, \
class TestPodBase(TestBase):
def setUp(self):
super(TestPodBase, self).setUp()
- self.req_d = PodCreateRequest('zte-1', 'virtual', 'zte pod 1','ci-pod')
+ 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 = '/pods'
+ self.basePath = '/api/v1/pods'
def assert_get_body(self, pod, req=None):
if not req:
@@ -21,7 +22,7 @@ class TestPodBase(TestBase):
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.assertEqual(pod.role, req.role)
self.assertIsNotNone(pod.creation_date)
self.assertIsNotNone(pod._id)
@@ -42,11 +43,6 @@ class TestPodCreate(TestPodBase):
self.assertEqual(code, HTTP_FORBIDDEN)
self.assertIn('already exists', body)
- def _assertMeta(self, meta, success):
- self.assertEqual(meta.success, success)
- if success:
- self.assertEqual(meta.uri, '/pods/{}'.format(self.req_d.name))
-
class TestPodGet(TestPodBase):
def test_notExist(self):
diff --git a/utils/test/result_collection_api/tests/unit/test_project.py b/utils/test/result_collection_api/tests/unit/test_project.py
index 6ce21db24..c38078098 100644
--- a/utils/test/result_collection_api/tests/unit/test_project.py
+++ b/utils/test/result_collection_api/tests/unit/test_project.py
@@ -14,7 +14,7 @@ class TestProjectBase(TestBase):
self.get_res = Project
self.list_res = Projects
self.update_res = Project
- self.basePath = '/projects'
+ self.basePath = '/api/v1/projects'
def assert_body(self, project, req=None):
if not req:
diff --git a/utils/test/result_collection_api/tests/unit/test_result.py b/utils/test/result_collection_api/tests/unit/test_result.py
index 9e27e3c3c..9c5093ed1 100644
--- a/utils/test/result_collection_api/tests/unit/test_result.py
+++ b/utils/test/result_collection_api/tests/unit/test_result.py
@@ -67,15 +67,17 @@ class TestResultBase(TestBase):
trust_indicator=self.trust_indicator)
self.get_res = TestResult
self.list_res = TestResults
- self.basePath = '/results'
+ self.basePath = '/api/v1/results'
self.req_pod = PodCreateRequest(self.pod, 'metal', 'zte pod 1')
self.req_project = ProjectCreateRequest(self.project, 'vping test')
self.req_testcase = TestcaseCreateRequest('/cases/vping',
self.case,
'vping-ssh test')
- self.create_help('/pods', self.req_pod)
- self.create_help('/projects', self.req_project)
- self.create_help('/projects/%s/cases', self.req_testcase, self.project)
+ self.create_help('/api/v1/pods', self.req_pod)
+ self.create_help('/api/v1/projects', self.req_project)
+ self.create_help('/api/v1/projects/%s/cases',
+ self.req_testcase,
+ self.project)
def assert_res(self, code, result):
self.assertEqual(code, HTTP_OK)
diff --git a/utils/test/result_collection_api/tests/unit/test_testcase.py b/utils/test/result_collection_api/tests/unit/test_testcase.py
index e44c0b4b6..712a4e78c 100644
--- a/utils/test/result_collection_api/tests/unit/test_testcase.py
+++ b/utils/test/result_collection_api/tests/unit/test_testcase.py
@@ -29,7 +29,7 @@ class TestCaseBase(TestBase):
self.get_res = Testcase
self.list_res = Testcases
self.update_res = Testcase
- self.basePath = '/projects/%s/cases'
+ self.basePath = '/api/v1/projects/%s/cases'
self.create_project()
def assert_body(self, case, req=None):
@@ -52,7 +52,7 @@ class TestCaseBase(TestBase):
def create_project(self):
req_p = ProjectCreateRequest('functest', 'vping-ssh test')
- self.create_help('/projects', req_p)
+ self.create_help('/api/v1/projects', req_p)
self.project = req_p.name
def create_d(self):
diff --git a/utils/test/result_collection_api/tests/unit/test_version.py b/utils/test/result_collection_api/tests/unit/test_version.py
index 918f2f052..a58cd5629 100644
--- a/utils/test/result_collection_api/tests/unit/test_version.py
+++ b/utils/test/result_collection_api/tests/unit/test_version.py
@@ -1,3 +1,4 @@
+import json
import unittest
from test_base import TestBase
@@ -5,10 +6,20 @@ from test_base import TestBase
__author__ = 'serena'
-class TestVersion(TestBase):
- def test_get_version(self):
- response = self.fetch('/version')
- self.assertEqual(response.code, 200)
+class TestVersionbBase(TestBase):
+ def setUp(self):
+ super(TestVersionbBase, self).setUp()
+ self.list_res = None
+ self.basePath = '/versions'
+
+
+class TestVersion(TestVersionbBase):
+ def test_success(self):
+ code, body = self.get()
+ self.assertEqual(200, code)
+ json_body = json.loads(body)
+ self.assertEqual(len(json_body), 1)
+ self.assertEqual('basics', json_body[0].get('v1'))
if __name__ == '__main__':
unittest.main()