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 TIHistory(object):
17 def __init__(self, date=None, step=0):
28 def from_dict(a_dict):
32 return TIHistory(a_dict.get('date'), a_dict.get('step'))
38 @property histories: trust_indicator update histories
39 @ptype histories: C{list} of L{TIHistory}
40 @ptype current: L{float}
42 def __init__(self, current=0):
43 self.current = current
44 self.histories = list()
48 for h in self.histories:
52 "current": self.current,
57 def from_dict(a_dict):
60 t.current = a_dict.get('current')
61 if 'histories' in a_dict.keys():
62 for history in a_dict.get('histories', None):
63 t.histories.append(TIHistory.from_dict(history))
70 class ResultCreateRequest(object):
72 @property trust_indicator:
73 @ptype trust_indicator: L{TI}
87 trust_indicator=None):
88 self.pod_name = pod_name
89 self.project_name = project_name
90 self.case_name = case_name
91 self.installer = installer
92 self.version = version
93 self.start_date = start_date
94 self.stop_date = stop_date
95 self.details = details
96 self.build_tag = build_tag
97 self.scenario = scenario
98 self.criteria = criteria
99 self.trust_indicator = trust_indicator if trust_indicator else TI(0)
103 "pod_name": self.pod_name,
104 "project_name": self.project_name,
105 "case_name": self.case_name,
106 "installer": self.installer,
107 "version": self.version,
108 "start_date": self.start_date,
109 "stop_date": self.stop_date,
110 "details": self.details,
111 "build_tag": self.build_tag,
112 "scenario": self.scenario,
113 "criteria": self.criteria,
114 "trust_indicator": self.trust_indicator.format()
119 class ResultUpdateRequest(object):
121 @property trust_indicator:
122 @ptype trust_indicator: L{TI}
124 def __init__(self, trust_indicator=None):
125 self.trust_indicator = trust_indicator
129 "trust_indicator": self.trust_indicator.format(),
134 class TestResult(object):
136 @property trust_indicator: used for long duration test case
137 @ptype trust_indicator: L{TI}
139 def __init__(self, _id=None, case_name=None, project_name=None,
140 pod_name=None, installer=None, version=None,
141 start_date=None, stop_date=None, details=None,
142 build_tag=None, scenario=None, criteria=None,
143 trust_indicator=None):
145 self.case_name = case_name
146 self.project_name = project_name
147 self.pod_name = pod_name
148 self.installer = installer
149 self.version = version
150 self.start_date = start_date
151 self.stop_date = stop_date
152 self.details = details
153 self.build_tag = build_tag
154 self.scenario = scenario
155 self.criteria = criteria
156 self.trust_indicator = trust_indicator
159 def from_dict(a_dict):
165 t._id = a_dict.get('_id')
166 t.case_name = a_dict.get('case_name')
167 t.pod_name = a_dict.get('pod_name')
168 t.project_name = a_dict.get('project_name')
169 t.start_date = str(a_dict.get('start_date'))
170 t.stop_date = str(a_dict.get('stop_date'))
171 t.details = a_dict.get('details')
172 t.version = a_dict.get('version')
173 t.installer = a_dict.get('installer')
174 t.build_tag = a_dict.get('build_tag')
175 t.scenario = a_dict.get('scenario')
176 t.criteria = a_dict.get('criteria')
177 t.trust_indicator = TI.from_dict(a_dict.get('trust_indicator'))
182 "case_name": self.case_name,
183 "project_name": self.project_name,
184 "pod_name": self.pod_name,
185 "start_date": str(self.start_date),
186 "stop_date": str(self.stop_date),
187 "version": self.version,
188 "installer": self.installer,
189 "details": self.details,
190 "build_tag": self.build_tag,
191 "scenario": self.scenario,
192 "criteria": self.criteria,
193 "trust_indicator": self.trust_indicator.format()
196 def format_http(self):
198 "_id": str(self._id),
199 "case_name": self.case_name,
200 "project_name": self.project_name,
201 "pod_name": self.pod_name,
202 "start_date": str(self.start_date),
203 "stop_date": str(self.stop_date),
204 "version": self.version,
205 "installer": self.installer,
206 "details": self.details,
207 "build_tag": self.build_tag,
208 "scenario": self.scenario,
209 "criteria": self.criteria,
210 "trust_indicator": self.trust_indicator.format()
215 class TestResults(object):
218 @ptype results: C{list} of L{TestResult}
221 self.results = list()
224 def from_dict(a_dict):
229 for result in a_dict.get('results'):
230 res.results.append(TestResult.from_dict(result))