def push_to_db(self):
"""Push the results of the test case to the DB.
It allows publishing the results and to check the status.
It could be overriden if the common implementation is not
suitable. The following attributes must be set before pushing
the results to DB:
* project_name,
* case_name,
* result,
* start_time,
* stop_time.
Returns:
TestCase.EX_OK if results were pushed to DB.
TestCase.EX_PUSH_TO_DB_ERROR otherwise.
"""
try:
assert self.project_name
assert self.case_name
assert self.start_time
assert self.stop_time
pub_result = 'PASS' if self.is_successful(
) == TestCase.EX_OK else 'FAIL'
if ft_utils.push_results_to_db(
self.project_name, self.case_name, self.start_time,
self.stop_time, pub_result, self.details):
self.__logger.info(
"The results were successfully pushed to DB")
return TestCase.EX_OK
else:
self.__logger.error("The results cannot be pushed to DB")
return TestCase.EX_PUSH_TO_DB_ERROR
except Exception: # pylint: disable=broad-except
self.__logger.exception("The results cannot be pushed to DB")
return TestCase.EX_PUSH_TO_DB_ERROR
评论列表
文章目录