From bc62769c5e525e4d0c47172397010b93bab64bb4 Mon Sep 17 00:00:00 2001 From: tmarenko Date: Wed, 14 Mar 2018 13:41:03 +0300 Subject: [PATCH] Finalizing launch with less copypaste --- reportportal_client/service.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/reportportal_client/service.py b/reportportal_client/service.py index c7bbec68..5652dffb 100644 --- a/reportportal_client/service.py +++ b/reportportal_client/service.py @@ -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):