1 ##############################################################################
2 # Copyright (c) 2015 Orange
3 # guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from opnfv_testapi.tornado_swagger import swagger
13 class ResultCreateRequest(object):
26 trust_indicator=None):
27 self.pod_name = pod_name
28 self.project_name = project_name
29 self.case_name = case_name
30 self.installer = installer
31 self.version = version
32 self.start_date = start_date
33 self.stop_date = stop_date
34 self.details = details
35 self.build_tag = build_tag
36 self.scenario = scenario
37 self.criteria = criteria
38 self.trust_indicator = trust_indicator
42 "pod_name": self.pod_name,
43 "project_name": self.project_name,
44 "case_name": self.case_name,
45 "installer": self.installer,
46 "version": self.version,
47 "start_date": self.start_date,
48 "stop_date": self.stop_date,
49 "details": self.details,
50 "build_tag": self.build_tag,
51 "scenario": self.scenario,
52 "criteria": self.criteria,
53 "trust_indicator": self.trust_indicator
58 class TestResult(object):
60 @property trust_indicator: must be int/long/float
61 @ptype trust_indicator: L{float}
63 def __init__(self, _id=None, case_name=None, project_name=None,
64 pod_name=None, installer=None, version=None,
65 start_date=None, stop_date=None, details=None,
66 build_tag=None, scenario=None, criteria=None,
67 trust_indicator=None):
69 self.case_name = case_name
70 self.project_name = project_name
71 self.pod_name = pod_name
72 self.installer = installer
73 self.version = version
74 self.start_date = start_date
75 self.stop_date = stop_date
76 self.details = details
77 self.build_tag = build_tag
78 self.scenario = scenario
79 self.criteria = criteria
80 self.trust_indicator = trust_indicator
83 def from_dict(a_dict):
89 t._id = a_dict.get('_id')
90 t.case_name = a_dict.get('case_name')
91 t.pod_name = a_dict.get('pod_name')
92 t.project_name = a_dict.get('project_name')
93 t.description = a_dict.get('description')
94 t.start_date = str(a_dict.get('start_date'))
95 t.stop_date = str(a_dict.get('stop_date'))
96 t.details = a_dict.get('details')
97 t.version = a_dict.get('version')
98 t.installer = a_dict.get('installer')
99 t.build_tag = a_dict.get('build_tag')
100 t.scenario = a_dict.get('scenario')
101 t.criteria = a_dict.get('criteria')
102 # 0 < trust indicator < 1
103 # if bad value => set this indicator to 0
104 t.trust_indicator = a_dict.get('trust_indicator')
105 if t.trust_indicator is not None:
106 if isinstance(t.trust_indicator, (int, long, float)):
107 if t.trust_indicator < 0:
108 t.trust_indicator = 0
109 elif t.trust_indicator > 1:
110 t.trust_indicator = 1
112 t.trust_indicator = 0
114 t.trust_indicator = 0
119 "case_name": self.case_name,
120 "project_name": self.project_name,
121 "pod_name": self.pod_name,
122 "description": self.description,
123 "start_date": str(self.start_date),
124 "stop_date": str(self.stop_date),
125 "version": self.version,
126 "installer": self.installer,
127 "details": self.details,
128 "build_tag": self.build_tag,
129 "scenario": self.scenario,
130 "criteria": self.criteria,
131 "trust_indicator": self.trust_indicator
134 def format_http(self):
136 "_id": str(self._id),
137 "case_name": self.case_name,
138 "project_name": self.project_name,
139 "pod_name": self.pod_name,
140 "description": self.description,
141 "start_date": str(self.start_date),
142 "stop_date": str(self.stop_date),
143 "version": self.version,
144 "installer": self.installer,
145 "details": self.details,
146 "build_tag": self.build_tag,
147 "scenario": self.scenario,
148 "criteria": self.criteria,
149 "trust_indicator": self.trust_indicator
154 class TestResults(object):
157 @ptype results: C{list} of L{TestResult}
160 self.results = list()
163 def from_dict(a_dict):
168 for result in a_dict.get('results'):
169 res.results.append(TestResult.from_dict(result))