Skip to content

Commit bc62769

Browse files
committed
Finalizing launch with less copypaste
1 parent a0c3d94 commit bc62769

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

reportportal_client/service.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,24 @@ def start_launch(self, name, start_time, description=None, tags=None,
128128
logger.debug("start_launch - Stack: %s", self.stack)
129129
return self.launch_id
130130

131-
def finish_launch(self, end_time, status=None):
131+
def _finalize_launch(self, end_time, action, status):
132132
data = {
133133
"end_time": end_time,
134134
"status": status
135135
}
136-
url = uri_join(self.base_url, "launch", self.launch_id, "finish")
136+
url = uri_join(self.base_url, "launch", self.launch_id, action)
137137
r = self.session.put(url=url, json=data)
138138
self.stack.pop()
139-
logger.debug("finish_launch - Stack: %s", self.stack)
139+
logger.debug("%s_launch - Stack: %s", action, self.stack)
140140
return _get_msg(r)
141141

142+
def finish_launch(self, end_time, status=None):
143+
return self._finalize_launch(end_time=end_time, action="finish",
144+
status=status)
145+
142146
def stop_launch(self, end_time, status=None):
143-
data = {
144-
"end_time": end_time,
145-
"status": status
146-
}
147-
url = uri_join(self.base_url, "launch", self.launch_id, "stop")
148-
r = self.session.put(url=url, json=data)
149-
self.stack.pop()
150-
logger.debug("stop_launch - Stack: %s", self.stack)
151-
return _get_msg(r)
147+
return self._finalize_launch(end_time=end_time, action="stop",
148+
status=status)
152149

153150
def start_test_item(self, name, start_time, item_type, description=None,
154151
tags=None):

0 commit comments

Comments
 (0)