diff options
Diffstat (limited to 'utils')
9 files changed, 54 insertions, 48 deletions
diff --git a/utils/test/result_collection_api/resources/handlers.py b/utils/test/result_collection_api/resources/handlers.py index 8cc68e912..435334341 100644 --- a/utils/test/result_collection_api/resources/handlers.py +++ b/utils/test/result_collection_api/resources/handlers.py @@ -73,10 +73,10 @@ class GenericApiHandler(RequestHandler): return CreateResponse(href=href).format() -class VersionHandler(RequestHandler): +class VersionHandler(GenericApiHandler): """ Display a message for the API version """ def get(self): - self.write("Collection of test result API, v1") + self.finish_request([{'v1': 'basics'}]) class PodHandler(GenericApiHandler): diff --git a/utils/test/result_collection_api/result_collection_api.py b/utils/test/result_collection_api/result_collection_api.py index 704d6075c..97aa58c77 100644 --- a/utils/test/result_collection_api/result_collection_api.py +++ b/utils/test/result_collection_api/result_collection_api.py @@ -54,25 +54,25 @@ def make_app(): return tornado.web.Application( [ # GET /version => GET API version - (r"/version", VersionHandler), + (r"/versions", VersionHandler), # few examples: # GET /pods => Get all pods # GET /pods/1 => Get details on POD 1 - (r"/pods", PodHandler), - (r"/pods/([^/]+)", PodHandler), + (r"/api/v1/pods", PodHandler), + (r"/api/v1/pods/([^/]+)", PodHandler), # few examples: # GET /projects # GET /projects/yardstick - (r"/projects", ProjectHandler), - (r"/projects/([^/]+)", ProjectHandler), + (r"/api/v1/projects", ProjectHandler), + (r"/api/v1/projects/([^/]+)", ProjectHandler), # few examples # GET /projects/qtip/cases => Get cases for qtip # - (r"/projects/([^/]+)/cases", TestcaseHandler), - (r"/projects/([^/]+)/cases/([^/]+)", TestcaseHandler), + (r"/api/v1/projects/([^/]+)/cases", TestcaseHandler), + (r"/api/v1/projects/([^/]+)/cases/([^/]+)", TestcaseHandler), # (r"/test_cases/([^/]+)", TestCasesHandler), # new path to avoid a long depth @@ -81,18 +81,17 @@ def make_app(): # POST /results => # Push results with mandatory request payload parameters # (project, case, and pod) - (r"/results", TestResultsHandler), - (r"/results([^/]*)", TestResultsHandler), - (r"/results/([^/]*)", TestResultsHandler), + (r"/api/v1/results", TestResultsHandler), + (r"/api/v1/results([^/]*)", TestResultsHandler), + (r"/api/v1/results/([^/]*)", TestResultsHandler), # Method to manage Dashboard ready results # GET /dashboard?project=functest&case=vPing&pod=opnfv-jump2 # => get results in dasboard ready format # get /dashboard # => get the list of project with dashboard ready results - (r"/dashboard", DashboardHandler), - (r"/dashboard([^/]*)", DashboardHandler), - (r"/dashboard/([^/]*)", DashboardHandler), + (r"/dashboard/v1/results", DashboardHandler), + (r"/dashboard/v1/results([^/]*)", DashboardHandler), ], db=db, debug=CONF.api_debug_on, 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 958a38f76..d7f4c3a63 100644 --- a/utils/test/result_collection_api/tests/unit/test_pod.py +++ b/utils/test/result_collection_api/tests/unit/test_pod.py @@ -14,7 +14,7 @@ class TestPodBase(TestBase): 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: @@ -43,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() |