summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/models/result_models.py
blob: 602318ad94844081a6473554f3f37154b86ccf1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
##############################################################################
# Copyright (c) 2015 Orange
# guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger


@swagger.model()
class ResultCreateRequest(base_models.ModelBase):
    def __init__(self,
                 pod_name=None,
                 project_name=None,
                 case_name=None,
                 installer=None,
                 version=None,
                 start_date=None,
                 stop_date=None,
                 details=None,
                 build_tag=None,
                 scenario=None,
                 criteria=None):
        self.pod_name = pod_name
        self.project_name = project_name
        self.case_name = case_name
        self.installer = installer
        self.version = version
        self.start_date = start_date
        self.stop_date = stop_date
        self.details = details
        self.build_tag = build_tag
        self.scenario = scenario
        self.criteria = criteria

    def __eq__(self, other):
        return all(getattr(self, k) == getattr(other, k)
                   for k in self.format().keys()
                   if k not in ['_id'])


@swagger.model()
class TestResult(ResultCreateRequest):
    def __init__(self, _id=None, **kwargs):
        super(TestResult, self).__init__(**kwargs)
        self._id = _id


@swagger.model()
class TestResults(base_models.ModelBase):
    """
        @property results:
        @ptype results: C{list} of L{TestResult}
    """
    def __init__(self):
        self.results = list()

    @staticmethod
    def attr_parser():
        return {'results': TestResult}