3 # Copyright (c) 2015 Orange
4 # morgan.richomme@orange.com
6 # This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # This script is used to build dashboard ready json results
13 # It may be used for all the test case of the Doctor project
14 # a new method format_<Test_case>_for_dashboard(results)
20 def get_doctor_cases():
22 get the list of the supported test cases
23 TODO: update the list when adding a new test case for the dashboard
25 return ["doctor-notification","doctor-mark-down"]
28 def format_doctor_for_dashboard(case, results):
30 generic method calling the method corresponding to the test case
31 check that the testcase is properly declared first
32 then build the call to the specific method
35 if check_doctor_case_exist(case):
36 # note we add _case because testcase and project had the same name
37 # TODO refactoring...looks fine at the beginning wit only 1 project
38 # not very ugly now and clearly not optimized...
39 cmd = "format_" + case.replace('-','_') + "_case_for_dashboard(results)"
46 def check_doctor_case_exist(case):
48 check if the testcase exists
49 if the test case is not defined or not declared in the list
52 doctor_cases = get_doctor_cases()
54 if (case is None or case not in doctor_cases):
60 def format_doctor_mark_down_case_for_dashboard(results):
62 Post processing for the doctor test case
64 test_data = [{'description': 'doctor-mark-down results for Dashboard'}]
68 def format_doctor_notification_case_for_dashboard(results):
70 Post processing for the doctor-notification test case
72 test_data = [{'description': 'doctor results for Dashboard'}]
73 # Graph 1: (duration)=f(time)
74 # ***************************************
77 # default duration 0:00:08.999904
78 # consider only seconds => 09
80 t = data['details']['duration']
81 new_element.append({'x': data['creation_date'],
84 test_data.append({'name': "doctor-notification duration ",
85 'info': {'type': "graph",
87 'ylabel': 'duration (s)'},
88 'data_set': new_element})
97 if data['details']['status'] == "OK":
100 test_data.append({'name': "doctor-notification status",
101 'info': {"type": "bar"},
102 'data_set': [{'Nb tests': nbTest,
103 'Nb Success': nbTestOk}]})