Skip to content

Commit

Permalink
Finalizing launch with less copypaste
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarenko committed Mar 14, 2018
1 parent a0c3d94 commit bc62769
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions reportportal_client/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,24 @@ def start_launch(self, name, start_time, description=None, tags=None,
logger.debug("start_launch - Stack: %s", self.stack)
return self.launch_id

def finish_launch(self, end_time, status=None):
def _finalize_launch(self, end_time, action, status):
data = {
"end_time": end_time,
"status": status
}
url = uri_join(self.base_url, "launch", self.launch_id, "finish")
url = uri_join(self.base_url, "launch", self.launch_id, action)
r = self.session.put(url=url, json=data)
self.stack.pop()
logger.debug("finish_launch - Stack: %s", self.stack)
logger.debug("%s_launch - Stack: %s", action, self.stack)
return _get_msg(r)

def finish_launch(self, end_time, status=None):
return self._finalize_launch(end_time=end_time, action="finish",
status=status)

def stop_launch(self, end_time, status=None):
data = {
"end_time": end_time,
"status": status
}
url = uri_join(self.base_url, "launch", self.launch_id, "stop")
r = self.session.put(url=url, json=data)
self.stack.pop()
logger.debug("stop_launch - Stack: %s", self.stack)
return _get_msg(r)
return self._finalize_launch(end_time=end_time, action="stop",
status=status)

def start_test_item(self, name, start_time, item_type, description=None,
tags=None):
Expand Down

0 comments on commit bc62769

Please sign in to comment.