summaryrefslogtreecommitdiffstats
path: root/utils/test/result_collection_api
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/result_collection_api')
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py16
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/resources/dashboard_handlers.py15
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/router/url_mappings.py4
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/tests/unit/test_dashboard_project.py20
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py9
5 files changed, 56 insertions, 8 deletions
diff --git a/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py b/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py
index 090aaa5b4..f331e28cd 100644
--- a/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py
+++ b/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py
@@ -67,6 +67,22 @@ def get_dashboard_cases():
return modules
+def get_dashboard_projects():
+ # Retrieve all the projects that could provide
+ # Dashboard ready graphs
+ # look in the releng repo
+ # search all the project2Dashboard.py files
+ # we assume that dashboard processing of project <Project>
+ # is performed in the <Project>2Dashboard.py file
+ projects = []
+ cp = re.compile('opnfv_testapi\.dashboard\.(.+?)2Dashboard')
+ for module in sys.modules:
+ project = re.findall(cp, module)
+ if project:
+ projects.extend(project)
+ return projects
+
+
def get_dashboard_result(project, case, results=None):
# get the dashboard ready results
# paramters are:
diff --git a/utils/test/result_collection_api/opnfv_testapi/resources/dashboard_handlers.py b/utils/test/result_collection_api/opnfv_testapi/resources/dashboard_handlers.py
index 84e7bc1b0..303e8d164 100644
--- a/utils/test/result_collection_api/opnfv_testapi/resources/dashboard_handlers.py
+++ b/utils/test/result_collection_api/opnfv_testapi/resources/dashboard_handlers.py
@@ -11,8 +11,8 @@ from tornado.web import HTTPError
from opnfv_testapi.common.constants import HTTP_NOT_FOUND
from opnfv_testapi.dashboard.dashboard_utils import \
- check_dashboard_ready_project, \
- check_dashboard_ready_case, get_dashboard_result
+ check_dashboard_ready_project, check_dashboard_ready_case, \
+ get_dashboard_result, get_dashboard_projects
from opnfv_testapi.resources.result_handlers import GenericResultHandler
from opnfv_testapi.resources.result_models import TestResult
from opnfv_testapi.tornado_swagger import swagger
@@ -107,3 +107,14 @@ class DashboardHandler(GenericDashboardHandler):
return get_dashboard_result(project, case, res)
self._list(self.set_query(), get_result, project_arg, case_arg)
+
+
+class DashboardProjectsHandler(GenericDashboardHandler):
+ @swagger.operation(nickname='list')
+ def get(self):
+ """
+ @description: Retrieve dashboard ready project(s)
+ @rtype: L{list}
+ @return 200: return all dashboard ready project(s)
+ """
+ self.finish_request(get_dashboard_projects())
diff --git a/utils/test/result_collection_api/opnfv_testapi/router/url_mappings.py b/utils/test/result_collection_api/opnfv_testapi/router/url_mappings.py
index 874754b91..695c27de1 100644
--- a/utils/test/result_collection_api/opnfv_testapi/router/url_mappings.py
+++ b/utils/test/result_collection_api/opnfv_testapi/router/url_mappings.py
@@ -14,7 +14,8 @@ from opnfv_testapi.resources.project_handlers import ProjectCLHandler, \
ProjectGURHandler
from opnfv_testapi.resources.result_handlers import ResultsCLHandler, \
ResultsGURHandler
-from opnfv_testapi.resources.dashboard_handlers import DashboardHandler
+from opnfv_testapi.resources.dashboard_handlers import DashboardHandler, \
+ DashboardProjectsHandler
mappings = [
@@ -53,4 +54,5 @@ mappings = [
# get /dashboard
# => get the list of project with dashboard ready results
(r"/dashboard/v1/results", DashboardHandler),
+ (r"/dashboard/v1/projects", DashboardProjectsHandler),
]
diff --git a/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_dashboard_project.py b/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_dashboard_project.py
new file mode 100644
index 000000000..f9d2015be
--- /dev/null
+++ b/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_dashboard_project.py
@@ -0,0 +1,20 @@
+import json
+
+from opnfv_testapi.common.constants import HTTP_OK
+from test_base import TestBase
+
+
+class TestDashboardProjectBase(TestBase):
+ def setUp(self):
+ super(TestDashboardProjectBase, self).setUp()
+ self.basePath = '/dashboard/v1/projects'
+ self.list_res = None
+ self.projects = ['bottlenecks', 'doctor', 'functest',
+ 'promise', 'qtip', 'vsperf', 'yardstick']
+
+
+class TestDashboardProjectGet(TestDashboardProjectBase):
+ def test_list(self):
+ code, body = self.get()
+ self.assertEqual(code, HTTP_OK)
+ self.assertItemsEqual(self.projects, json.loads(body))
diff --git a/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py b/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py
index fc1e9bacd..5a5dd3852 100644
--- a/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py
+++ b/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py
@@ -7,16 +7,15 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import unittest
-import copy
-from test_base import TestBase
+from opnfv_testapi.common.constants import HTTP_OK, HTTP_BAD_REQUEST, \
+ HTTP_NOT_FOUND
from opnfv_testapi.resources.pod_models import PodCreateRequest
from opnfv_testapi.resources.project_models import ProjectCreateRequest
-from opnfv_testapi.resources.testcase_models import TestcaseCreateRequest
from opnfv_testapi.resources.result_models import ResultCreateRequest, \
TestResult, TestResults
-from opnfv_testapi.common.constants import HTTP_OK, HTTP_BAD_REQUEST, \
- HTTP_NOT_FOUND
+from opnfv_testapi.resources.testcase_models import TestcaseCreateRequest
+from test_base import TestBase
class Details(object):