1
1
import logging
2
2
import traceback
3
3
from time import time
4
- from reportportal_client import ReportPortalServiceAsync
5
- from .variables import Variables
4
+ from reportportal_client import ReportPortalService
6
5
7
6
8
7
def async_error_handler (exc_info ):
@@ -34,18 +33,16 @@ class RobotService(object):
34
33
}
35
34
36
35
@staticmethod
37
- def init_service (endpoint , project , uuid , log_batch_size ):
36
+ def init_service (endpoint , project , uuid ):
38
37
if RobotService .rp is None :
39
38
logging .debug (
40
39
"ReportPortal - Init service: "
41
40
"endpoint={0}, project={1}, uuid={2}"
42
41
.format (endpoint , project , uuid ))
43
- RobotService .rp = ReportPortalServiceAsync (
42
+ RobotService .rp = ReportPortalService (
44
43
endpoint = endpoint ,
45
44
project = project ,
46
- token = uuid ,
47
- error_handler = async_error_handler ,
48
- log_batch_size = log_batch_size )
45
+ token = uuid )
49
46
else :
50
47
raise Exception ("RobotFrameworkService is already initialized" )
51
48
@@ -60,12 +57,11 @@ def start_launch(launch_name, mode=None, launch=None):
60
57
"name" : launch_name ,
61
58
"start_time" : timestamp (),
62
59
"description" : launch .doc ,
63
- "mode" : mode ,
64
- "tags" : Variables .launch_tags
60
+ "mode" : mode
65
61
}
66
62
logging .debug ("ReportPortal - Start launch: "
67
63
"request_body={0}" .format (sl_pt ))
68
- RobotService .rp .start_launch (** sl_pt )
64
+ return RobotService .rp .start_launch (** sl_pt )
69
65
70
66
@staticmethod
71
67
def finish_launch (launch = None ):
@@ -78,77 +74,81 @@ def finish_launch(launch=None):
78
74
RobotService .rp .finish_launch (** fl_rq )
79
75
80
76
@staticmethod
81
- def start_suite (name = None , suite = None ):
77
+ def start_suite (name = None , suite = None , parent_item_id = None ):
82
78
start_rq = {
83
79
"name" : name ,
84
80
"description" : suite .doc ,
85
- "tags" : [],
86
81
"start_time" : timestamp (),
87
- "item_type" : "SUITE"
82
+ "item_type" : "SUITE" ,
83
+ "parent_item_id" : parent_item_id
88
84
}
89
85
logging .debug (
90
86
"ReportPortal - Start suite: "
91
87
"request_body={0}" .format (start_rq ))
92
- RobotService .rp .start_test_item (** start_rq )
88
+ return RobotService .rp .start_test_item (** start_rq )
93
89
94
90
@staticmethod
95
- def finish_suite (issue = None , suite = None ):
91
+ def finish_suite (item_id , issue = None , suite = None ):
96
92
fta_rq = {
97
93
"end_time" : timestamp (),
98
94
"status" : RobotService .status_mapping [suite .status ],
99
- "issue" : issue
95
+ "issue" : issue ,
96
+ "item_id" : item_id
100
97
}
101
98
logging .debug (
102
99
"ReportPortal - Finish suite:"
103
100
" request_body={0}" .format (fta_rq ))
104
101
RobotService .rp .finish_test_item (** fta_rq )
105
102
106
103
@staticmethod
107
- def start_test (test = None ):
104
+ def start_test (test = None , parent_item_id = None ):
108
105
start_rq = {
109
106
"name" : test .name ,
110
107
"description" : test .doc ,
111
- "tags" : test .tags ,
112
108
"start_time" : timestamp (),
113
- "item_type" : "TEST"
109
+ "item_type" : "TEST" ,
110
+ "parent_item_id" : parent_item_id
114
111
}
115
112
logging .debug (
116
113
"ReportPortal - Start test: "
117
114
"request_body={0}" .format (start_rq ))
118
- RobotService .rp .start_test_item (** start_rq )
115
+ return RobotService .rp .start_test_item (** start_rq )
119
116
120
117
@staticmethod
121
- def finish_test (issue = None , test = None ):
118
+ def finish_test (item_id , issue = None , test = None ):
122
119
fta_rq = {
123
120
"end_time" : timestamp (),
124
121
"status" : RobotService .status_mapping [test .status ],
125
- "issue" : issue
122
+ "issue" : issue ,
123
+ "item_id" : item_id
126
124
}
127
125
logging .debug (
128
126
"ReportPortal - Finish test:"
129
127
" request_body={0}" .format (fta_rq ))
130
128
RobotService .rp .finish_test_item (** fta_rq )
131
129
132
130
@staticmethod
133
- def start_keyword (keyword = None ):
131
+ def start_keyword (keyword = None , parent_item_id = None , has_stats = True ):
134
132
start_rq = {
135
133
"name" : keyword .get_name (),
136
134
"description" : keyword .doc ,
137
- "tags" : keyword .tags ,
138
135
"start_time" : timestamp (),
139
- "item_type" : keyword .get_type ()
136
+ "item_type" : keyword .get_type (),
137
+ "parent_item_id" : parent_item_id ,
138
+ "has_stats" : has_stats
140
139
}
141
140
logging .debug (
142
141
"ReportPortal - Start keyword: "
143
142
"request_body={0}" .format (start_rq ))
144
- RobotService .rp .start_test_item (** start_rq )
143
+ return RobotService .rp .start_test_item (** start_rq )
145
144
146
145
@staticmethod
147
- def finish_keyword (issue = None , keyword = None ):
146
+ def finish_keyword (item_id , issue = None , keyword = None ):
148
147
fta_rq = {
149
148
"end_time" : timestamp (),
150
149
"status" : RobotService .status_mapping [keyword .status ],
151
- "issue" : issue
150
+ "issue" : issue ,
151
+ "item_id" : item_id
152
152
}
153
153
logging .debug (
154
154
"ReportPortal - Finish keyword:"
0 commit comments