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 # feng.xiaowei@zte.com.cn mv TestCase to testcase_models.py 5-20-2016
\r
14 ##############################################################################
\r
17 class CreateResponse(object):
\r
18 def __init__(self, href=''):
\r
22 def from_dict(res_dict):
\r
23 if res_dict is None:
\r
26 res = CreateResponse()
\r
27 res.href = res_dict.get('href')
\r
31 return {'href': self.href}
\r
35 """ Describes a test result"""
\r
39 self.case_name = None
\r
40 self.project_name = None
\r
41 self.pod_name = None
\r
42 self.installer = None
\r
44 self.description = None
\r
45 self.creation_date = None
\r
47 self.build_tag = None
\r
48 self.scenario = None
\r
49 self.criteria = None
\r
50 self.trust_indicator = None
\r
53 def test_result_from_dict(test_result_dict):
\r
55 if test_result_dict is None:
\r
59 t._id = test_result_dict.get('_id')
\r
60 t.case_name = test_result_dict.get('case_name')
\r
61 t.pod_name = test_result_dict.get('pod_name')
\r
62 t.project_name = test_result_dict.get('project_name')
\r
63 t.description = test_result_dict.get('description')
\r
64 t.creation_date = str(test_result_dict.get('creation_date'))
\r
65 t.details = test_result_dict.get('details')
\r
66 t.version = test_result_dict.get('version')
\r
67 t.installer = test_result_dict.get('installer')
\r
68 t.build_tag = test_result_dict.get('build_tag')
\r
69 t.scenario = test_result_dict.get('scenario')
\r
70 t.criteria = test_result_dict.get('criteria')
\r
71 # 0 < trust indicator < 1
\r
72 # if bad value => set this indicator to 0
\r
73 if test_result_dict.get('trust_indicator') is not None:
\r
74 if isinstance(test_result_dict.get('trust_indicator'),
\r
75 (int, long, float)):
\r
76 if test_result_dict.get('trust_indicator') < 0:
\r
77 t.trust_indicator = 0
\r
78 elif test_result_dict.get('trust_indicator') > 1:
\r
79 t.trust_indicator = 1
\r
81 t.trust_indicator = test_result_dict.get('trust_indicator')
\r
83 t.trust_indicator = 0
\r
85 t.trust_indicator = 0
\r
90 "case_name": self.case_name,
\r
91 "project_name": self.project_name,
\r
92 "pod_name": self.pod_name,
\r
93 "description": self.description,
\r
94 "creation_date": str(self.creation_date),
\r
95 "version": self.version,
\r
96 "installer": self.installer,
\r
97 "details": self.details,
\r
98 "build_tag": self.build_tag,
\r
99 "scenario": self.scenario,
\r
100 "criteria": self.criteria,
\r
101 "trust_indicator": self.trust_indicator
\r
104 def format_http(self):
\r
106 "_id": str(self._id),
\r
107 "case_name": self.case_name,
\r
108 "project_name": self.project_name,
\r
109 "pod_name": self.pod_name,
\r
110 "description": self.description,
\r
111 "creation_date": str(self.creation_date),
\r
112 "version": self.version,
\r
113 "installer": self.installer,
\r
114 "details": self.details,
\r
115 "build_tag": self.build_tag,
\r
116 "scenario": self.scenario,
\r
117 "criteria": self.criteria,
\r
118 "trust_indicator": self.trust_indicator
\r