1 ##############################################################################
\r
2 # Copyright (c) 2015 Orange
\r
3 # guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
\r
4 # All rights reserved. This program and the accompanying materials
\r
5 # are made available under the terms of the Apache License, Version 2.0
\r
6 # which accompanies this distribution, and is available at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
8 # feng.xiaowei@zte.com.cn mv Pod to pod_models.py 5-18-2016
\r
9 # feng.xiaowei@zte.com.cn add MetaCreateResponse/MetaGetResponse 5-18-2016
\r
10 # feng.xiaowei@zte.com.cn mv TestProject to project_models.py 5-19-2016
\r
11 # feng.xiaowei@zte.com.cn delete meta class 5-19-2016
\r
12 # feng.xiaowei@zte.com.cn add CreateResponse 5-19-2016
\r
13 ##############################################################################
\r
16 class CreateResponse(object):
\r
17 def __init__(self, href=''):
\r
21 def from_dict(res_dict):
\r
22 if res_dict is None:
\r
25 res = CreateResponse()
\r
26 res.href = res_dict.get('href')
\r
30 return {'href': self.href}
\r
34 """ Describes a test case"""
\r
39 self.project_name = None
\r
40 self.description = None
\r
42 self.creation_date = None
\r
45 def test_case_from_dict(testcase_dict):
\r
47 if testcase_dict is None:
\r
51 t._id = testcase_dict.get('_id')
\r
52 t.project_name = testcase_dict.get('project_name')
\r
53 t.creation_date = testcase_dict.get('creation_date')
\r
54 t.name = testcase_dict.get('name')
\r
55 t.description = testcase_dict.get('description')
\r
56 t.url = testcase_dict.get('url')
\r
63 "description": self.description,
\r
64 "project_name": self.project_name,
\r
65 "creation_date": str(self.creation_date),
\r
69 def format_http(self, test_project=None):
\r
71 "_id": str(self._id),
\r
73 "description": self.description,
\r
74 "creation_date": str(self.creation_date),
\r
77 if test_project is not None:
\r
78 res["test_project"] = test_project
\r
84 """ Describes a test result"""
\r
88 self.case_name = None
\r
89 self.project_name = None
\r
90 self.pod_name = None
\r
91 self.installer = None
\r
93 self.description = None
\r
94 self.creation_date = None
\r
96 self.build_tag = None
\r
97 self.scenario = None
\r
98 self.criteria = None
\r
99 self.trust_indicator = None
\r
102 def test_result_from_dict(test_result_dict):
\r
104 if test_result_dict is None:
\r
108 t._id = test_result_dict.get('_id')
\r
109 t.case_name = test_result_dict.get('case_name')
\r
110 t.pod_name = test_result_dict.get('pod_name')
\r
111 t.project_name = test_result_dict.get('project_name')
\r
112 t.description = test_result_dict.get('description')
\r
113 t.creation_date = str(test_result_dict.get('creation_date'))
\r
114 t.details = test_result_dict.get('details')
\r
115 t.version = test_result_dict.get('version')
\r
116 t.installer = test_result_dict.get('installer')
\r
117 t.build_tag = test_result_dict.get('build_tag')
\r
118 t.scenario = test_result_dict.get('scenario')
\r
119 t.criteria = test_result_dict.get('criteria')
\r
120 # 0 < trust indicator < 1
\r
121 # if bad value => set this indicator to 0
\r
122 if test_result_dict.get('trust_indicator') is not None:
\r
123 if isinstance(test_result_dict.get('trust_indicator'),
\r
124 (int, long, float)):
\r
125 if test_result_dict.get('trust_indicator') < 0:
\r
126 t.trust_indicator = 0
\r
127 elif test_result_dict.get('trust_indicator') > 1:
\r
128 t.trust_indicator = 1
\r
130 t.trust_indicator = test_result_dict.get('trust_indicator')
\r
132 t.trust_indicator = 0
\r
134 t.trust_indicator = 0
\r
139 "case_name": self.case_name,
\r
140 "project_name": self.project_name,
\r
141 "pod_name": self.pod_name,
\r
142 "description": self.description,
\r
143 "creation_date": str(self.creation_date),
\r
144 "version": self.version,
\r
145 "installer": self.installer,
\r
146 "details": self.details,
\r
147 "build_tag": self.build_tag,
\r
148 "scenario": self.scenario,
\r
149 "criteria": self.criteria,
\r
150 "trust_indicator": self.trust_indicator
\r
153 def format_http(self):
\r
155 "_id": str(self._id),
\r
156 "case_name": self.case_name,
\r
157 "project_name": self.project_name,
\r
158 "pod_name": self.pod_name,
\r
159 "description": self.description,
\r
160 "creation_date": str(self.creation_date),
\r
161 "version": self.version,
\r
162 "installer": self.installer,
\r
163 "details": self.details,
\r
164 "build_tag": self.build_tag,
\r
165 "scenario": self.scenario,
\r
166 "criteria": self.criteria,
\r
167 "trust_indicator": self.trust_indicator
\r