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):
61 t.current = a_dict.get('current')
62 if 'histories' in a_dict.keys():
63 for history in a_dict.get('histories', None):
64 t.histories.append(TIHistory.from_dict(history))
71 class ResultCreateRequest(object):
73 @property trust_indicator:
74 @ptype trust_indicator: L{TI}
88 trust_indicator=None):
89 self.pod_name = pod_name
90 self.project_name = project_name
91 self.case_name = case_name
92 self.installer = installer
93 self.version = version
94 self.start_date = start_date
95 self.stop_date = stop_date
96 self.details = details
97 self.build_tag = build_tag
98 self.scenario = scenario
99 self.criteria = criteria
100 self.trust_indicator = trust_indicator
104 "pod_name": self.pod_name,
105 "project_name": self.project_name,
106 "case_name": self.case_name,
107 "installer": self.installer,
108 "version": self.version,
109 "start_date": self.start_date,
110 "stop_date": self.stop_date,
111 "details": self.details,
112 "build_tag": self.build_tag,
113 "scenario": self.scenario,
114 "criteria": self.criteria,
115 "trust_indicator": self.trust_indicator.format()
120 class ResultUpdateRequest(object):
122 @property trust_indicator:
123 @ptype trust_indicator: L{TI}
125 def __init__(self, trust_indicator=None):
126 self.trust_indicator = trust_indicator
130 "trust_indicator": self.trust_indicator.format(),
135 class TestResult(object):
137 @property trust_indicator: used for long duration test case
138 @ptype trust_indicator: L{TI}
140 def __init__(self, _id=None, case_name=None, project_name=None,
141 pod_name=None, installer=None, version=None,
142 start_date=None, stop_date=None, details=None,
143 build_tag=None, scenario=None, criteria=None,
144 trust_indicator=None):
146 self.case_name = case_name
147 self.project_name = project_name
148 self.pod_name = pod_name
149 self.installer = installer
150 self.version = version
151 self.start_date = start_date
152 self.stop_date = stop_date
153 self.details = details
154 self.build_tag = build_tag
155 self.scenario = scenario
156 self.criteria = criteria
157 self.trust_indicator = trust_indicator
160 def from_dict(a_dict):
166 t._id = a_dict.get('_id')
167 t.case_name = a_dict.get('case_name')
168 t.pod_name = a_dict.get('pod_name')
169 t.project_name = a_dict.get('project_name')
170 t.start_date = str(a_dict.get('start_date'))
171 t.stop_date = str(a_dict.get('stop_date'))
172 t.details = a_dict.get('details')
173 t.version = a_dict.get('version')
174 t.installer = a_dict.get('installer')
175 t.build_tag = a_dict.get('build_tag')
176 t.scenario = a_dict.get('scenario')
177 t.criteria = a_dict.get('criteria')
178 t.trust_indicator = TI.from_dict(a_dict.get('trust_indicator'))
183 "case_name": self.case_name,
184 "project_name": self.project_name,
185 "pod_name": self.pod_name,
186 "start_date": str(self.start_date),
187 "stop_date": str(self.stop_date),
188 "version": self.version,
189 "installer": self.installer,
190 "details": self.details,
191 "build_tag": self.build_tag,
192 "scenario": self.scenario,
193 "criteria": self.criteria,
194 "trust_indicator": self.trust_indicator.format()
197 def format_http(self):
199 "_id": str(self._id),
200 "case_name": self.case_name,
201 "project_name": self.project_name,
202 "pod_name": self.pod_name,
203 "start_date": str(self.start_date),
204 "stop_date": str(self.stop_date),
205 "version": self.version,
206 "installer": self.installer,
207 "details": self.details,
208 "build_tag": self.build_tag,
209 "scenario": self.scenario,
210 "criteria": self.criteria,
211 "trust_indicator": self.trust_indicator.format()
216 class TestResults(object):
219 @ptype results: C{list} of L{TestResult}
222 self.results = list()
225 def from_dict(a_dict):
230 for result in a_dict.get('results'):
231 res.results.append(TestResult.from_dict(result))