From 0c898e11323cf4e5baabecb55d8be2ff2268690d Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Mon, 23 May 2016 18:34:19 +0800 Subject: add test result/dashboard related unittests in testAPI and refactor its response modification: add unittests for test result/dashboard rename test_results table name in db to results refactor response body JIRA: FUNCTEST-255 Change-Id: I0657e6e95156a8c79072e7333fd8aaeb12d986e5 Signed-off-by: SerenaFeng --- result_collection_api/dashboard/dashboard_utils.py | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'result_collection_api/dashboard/dashboard_utils.py') 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__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 # is performed in the 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): -- cgit 1.2.3-korg