-
Notifications
You must be signed in to change notification settings - Fork 32
/
model.py
88 lines (77 loc) · 2.96 KB
/
model.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from six import text_type
from reportportal_client.service import _convert_string
class Suite(object):
def __init__(self, attributes):
super(Suite, self).__init__()
self.attributes = attributes
self.suites = attributes["suites"]
self.tests = attributes["tests"]
self.doc = attributes["doc"]
self.source = attributes["source"]
self.total_tests = attributes["totaltests"]
self.longname = attributes["longname"]
self.robot_id = attributes["id"]
self.metadata = attributes["metadata"]
self.status = None
self.message = None
self.statistics = None
if "status" in attributes.keys():
self.status = attributes["status"]
if "message" in attributes.keys():
self.message = attributes["message"]
if "statistics" in attributes.keys():
self.statistics = attributes["statistics"]
class Test(object):
def __init__(self, name=None, attributes=None):
super(Test, self).__init__()
self.name = name
self.critical = attributes["critical"]
self.template = attributes["template"]
self.tags = attributes["tags"]
self.doc = attributes["doc"]
self.longname = attributes["longname"]
self.robot_id = attributes["id"]
self.status = None
self.message = None
if "status" in attributes.keys():
self.status = attributes["status"]
if "message" in attributes.keys():
self.message = attributes["message"]
class Keyword(object):
def __init__(self, name=None, parent_type="TEST", attributes=None):
super(Keyword, self).__init__()
self.name = name
self.libname = attributes["libname"]
self.keyword_name = attributes["kwname"]
self.doc = attributes["doc"]
self.tags = attributes["tags"]
self.args = attributes["args"]
self.assign = attributes["assign"]
self.keyword_type = attributes["type"]
self.parent_type = parent_type
if "status" in attributes.keys():
self.status = attributes["status"]
def get_name(self):
assign = _convert_string(", ".join(self.assign))
assignment = "{0} = ".format(assign) if self.assign else ""
arguments = ", ".join(self.args)
full_name = "{0}{1} ({2})".format(
assignment,
_convert_string(self.name),
_convert_string(arguments)
)
return full_name[:256]
def get_type(self):
if self.keyword_type == "Setup":
return "BEFORE_{0}".format(self.parent_type)
elif self.keyword_type == "Teardown":
return "AFTER_{0}".format(self.parent_type)
else:
return "STEP"
class LogMessage(text_type):
def __init__(self, *args, **kwargs):
super(LogMessage, self).__init__()
self.item_id = None
self.message = self
self.level = "INFO"
self.attachment = None