summaryrefslogtreecommitdiffstats
path: root/result_collection_api/dashboard/dashboard_utils.py
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-05-25 09:50:08 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-05-25 09:50:08 +0000
commitf204fed9d8519f994b085a1139f036bc40fcddbc (patch)
tree9e90094bbb1760363d666b8ad1c52b99ad730fab /result_collection_api/dashboard/dashboard_utils.py
parent02825c3c21fc5c46d4952c1410f96e3836b50b61 (diff)
parent0c898e11323cf4e5baabecb55d8be2ff2268690d (diff)
Merge "add test result/dashboard related unittests in testAPI and refactor its response"
Diffstat (limited to 'result_collection_api/dashboard/dashboard_utils.py')
-rw-r--r--result_collection_api/dashboard/dashboard_utils.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/result_collection_api/dashboard/dashboard_utils.py b/result_collection_api/dashboard/dashboard_utils.py
index 472bbc7..bfa7432 100644
--- a/result_collection_api/dashboard/dashboard_utils.py
+++ b/result_collection_api/dashboard/dashboard_utils.py
@@ -16,6 +16,7 @@
#
import os
import re
+import sys
from functest2Dashboard import format_functest_for_dashboard, \
check_functest_case_exist
from yardstick2Dashboard import format_yardstick_for_dashboard, \
@@ -37,16 +38,12 @@ from doctor2Dashboard import format_doctor_for_dashboard, \
# - check_<Project>_case_exist
-def check_dashboard_ready_project(test_project, path):
+def check_dashboard_ready_project(test_project):
# Check that the first param corresponds to a project
# for whoch dashboard processing is available
- subdirectories = os.listdir(path)
- for testfile in subdirectories:
- m = re.search('^(.*)(2Dashboard.py)$', testfile)
- if m:
- if (m.group(1) == test_project):
- return True
- return False
+ # print("test_project: %s" % test_project)
+ project_module = 'dashboard.'+test_project + '2Dashboard'
+ return True if project_module in sys.modules else False
def check_dashboard_ready_case(project, case):
@@ -54,21 +51,20 @@ def check_dashboard_ready_case(project, case):
return eval(cmd)
-def get_dashboard_cases(path):
+def get_dashboard_cases():
# Retrieve all the test cases 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
- dashboard_test_cases = []
- subdirectories = os.listdir(path)
- for testfile in subdirectories:
- m = re.search('^(.*)(2Dashboard.py)$', testfile)
- if m:
- dashboard_test_cases.append(m.group(1))
+ modules = []
+ cp = re.compile('dashboard.*2Dashboard')
+ for module in sys.modules:
+ if re.match(cp, module):
+ modules.append(module)
- return dashboard_test_cases
+ return modules
def get_dashboard_result(project, case, results):