def test_warn(self): # Time is beyond warn deadline but within close deadline. There isn't a # comment yet, so a comment should be posted. self.open_pull_requests.return_value = ['123'] self.last_commit_date.return_value = now() - 230 self.find_comments.return_value = [] with app.app_context(): process_pull_requests('repo', 'installation') assert self.submit_comment.call_count == 1 expected = PULL_REQUESTS_CLOSE_WARNING.format(pasttime='3 minutes', futuretime='20 seconds') self.submit_comment.assert_called_with(expected) assert self.close.call_count == 0
def test_close_keep_open_label(self): # Time is beyond close deadline, and there is no comment yet but there # is a keep-open label self.open_pull_requests.return_value = ['123'] self.last_commit_date.return_value = now() - 241 self.find_comments.return_value = [] with app.app_context(): with patch.object(app, 'stale_pull_requests_close', False): process_pull_requests('repo', 'installation') assert self.submit_comment.call_count == 1 expected = PULL_REQUESTS_CLOSE_WARNING.format(pasttime='4 minutes', futuretime='20 seconds') self.submit_comment.assert_called_with(expected) assert self.close.call_count == 0
def test_close_disabled(self): # Time is beyond close deadline, and there is no comment yet but the # global option to allow closing has not been enabled. Since there is no # comment, the warning gets posted (rather than the 'epilogue') self.open_pull_requests.return_value = ['123'] self.last_commit_date.return_value = now() - 241 self.find_comments.return_value = [] with app.app_context(): with patch.object(app, 'stale_pull_requests_close', False): process_pull_requests('repo', 'installation') assert self.submit_comment.call_count == 1 expected = PULL_REQUESTS_CLOSE_WARNING.format(pasttime='4 minutes', futuretime='20 seconds') self.submit_comment.assert_called_with(expected) assert self.close.call_count == 0