Merge "big fixes: wrong path"
[releng.git] / utils / test / testapi / opnfv_testapi / resources / result_models.py
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.resources import models
10 from opnfv_testapi.tornado_swagger import swagger
11
12
13 @swagger.model()
14 class TIHistory(models.ModelBase):
15     """
16         @ptype step: L{float}
17     """
18     def __init__(self, date=None, step=0):
19         self.date = date
20         self.step = step
21
22
23 @swagger.model()
24 class TI(models.ModelBase):
25     """
26         @property histories: trust_indicator update histories
27         @ptype histories: C{list} of L{TIHistory}
28         @ptype current: L{float}
29     """
30     def __init__(self, current=0):
31         self.current = current
32         self.histories = list()
33
34     @staticmethod
35     def attr_parser():
36         return {'histories': TIHistory}
37
38
39 @swagger.model()
40 class ResultCreateRequest(models.ModelBase):
41     """
42         @property trust_indicator:
43         @ptype trust_indicator: L{TI}
44     """
45     def __init__(self,
46                  pod_name=None,
47                  project_name=None,
48                  case_name=None,
49                  installer=None,
50                  version=None,
51                  start_date=None,
52                  stop_date=None,
53                  details=None,
54                  build_tag=None,
55                  scenario=None,
56                  criteria=None,
57                  trust_indicator=None):
58         self.pod_name = pod_name
59         self.project_name = project_name
60         self.case_name = case_name
61         self.installer = installer
62         self.version = version
63         self.start_date = start_date
64         self.stop_date = stop_date
65         self.details = details
66         self.build_tag = build_tag
67         self.scenario = scenario
68         self.criteria = criteria
69         self.trust_indicator = trust_indicator if trust_indicator else TI(0)
70
71
72 @swagger.model()
73 class ResultUpdateRequest(models.ModelBase):
74     """
75         @property trust_indicator:
76         @ptype trust_indicator: L{TI}
77     """
78     def __init__(self, trust_indicator=None):
79         self.trust_indicator = trust_indicator
80
81
82 @swagger.model()
83 class TestResult(models.ModelBase):
84     """
85         @property trust_indicator: used for long duration test case
86         @ptype trust_indicator: L{TI}
87     """
88     def __init__(self, _id=None, case_name=None, project_name=None,
89                  pod_name=None, installer=None, version=None,
90                  start_date=None, stop_date=None, details=None,
91                  build_tag=None, scenario=None, criteria=None,
92                  trust_indicator=None):
93         self._id = _id
94         self.case_name = case_name
95         self.project_name = project_name
96         self.pod_name = pod_name
97         self.installer = installer
98         self.version = version
99         self.start_date = start_date
100         self.stop_date = stop_date
101         self.details = details
102         self.build_tag = build_tag
103         self.scenario = scenario
104         self.criteria = criteria
105         self.trust_indicator = trust_indicator
106
107     @staticmethod
108     def attr_parser():
109         return {'trust_indicator': TI}
110
111
112 @swagger.model()
113 class TestResults(models.ModelBase):
114     """
115         @property results:
116         @ptype results: C{list} of L{TestResult}
117     """
118     def __init__(self):
119         self.results = list()
120
121     @staticmethod
122     def attr_parser():
123         return {'results': TestResult}