def test_bad_2(self): # Change log has multiple issues. self.changelog_cfg.return_value = True self.labels.return_value = [] self.issues.return_value = ['One issue', 'OMG another one'] self.comment_ids.return_value = [] expected = (CHANGELOG_PROLOGUE.format(user='******') + CHANGELOG_BAD_LIST + '* {0}\n'.format('One issue') + '* {0}\n'.format('OMG another one') + CHANGELOG_BAD_EPILOGUE + CHANGELOG_EPILOGUE) with app.app_context(): process_changelog_consistency('repo', '1234', 'installation') assert self.issues.call_count == 1 self.submit_comment.assert_called_with(expected, comment_id=None, return_url=True) self.set_status.assert_called_with( 'failure', 'There were failures in checks - see ' 'comments by @stsci-bot above', 'stsci-bot', target_url='url')
def test_bad_1(self): # Change log has 1 issue. self.changelog_cfg.return_value = True self.labels.return_value = [] self.issues.return_value = ['One issue'] self.comment_ids.return_value = ['123'] expected = (CHANGELOG_PROLOGUE.format(user='******') + CHANGELOG_BAD_LIST + '* {0}\n'.format('One issue') + CHANGELOG_BAD_EPILOGUE) expected = (expected.replace('issues with', 'issue with').replace( 'fix these', 'fix this')) expected += CHANGELOG_EPILOGUE with app.app_context(): process_changelog_consistency('repo', '1234', 'installation') assert self.issues.call_count == 1 self.submit_comment.assert_called_with(expected, comment_id='123', return_url=True) self.set_status.assert_called_with( 'failure', 'There were failures in checks - see ' 'comments by @astropy-bot above', 'astropy-bot', target_url='url')
def test_config_noop(self): # Repo does not want any changelog check. self.changelog_cfg.return_value = False with app.app_context(): process_changelog_consistency('repo', '1234', 'installation') assert self.issues.call_count == 0
def test_good(self): # Change log has no issue. self.changelog_cfg.return_value = True self.labels.return_value = [] self.issues.return_value = [] self.comment_ids.return_value = ['123', '456'] expected = (CHANGELOG_PROLOGUE.format(user='******') + CHANGELOG_GOOD + CHANGELOG_EPILOGUE) with app.app_context(): process_changelog_consistency('repo', '1234', 'installation') assert self.issues.call_count == 1 self.submit_comment.assert_called_with(expected, comment_id='456', return_url=True) self.set_status.assert_called_with('success', 'All checks passed', 'stsci-bot', target_url='url')
def test_work_in_progress(self): # Pull request is work in progress. Don't check change log yet but # leave a comment. self.changelog_cfg.return_value = True self.labels.return_value = ['Work in progress'] expected = (CHANGELOG_PROLOGUE.format(user='******') + CHANGELOG_NOT_DONE.format(status='a work in progress', is_done='is ready for review') + CHANGELOG_EPILOGUE) with app.app_context(): process_changelog_consistency('repo', '1234', 'installation') assert self.issues.call_count == 0 self.submit_comment.assert_called_with(expected, comment_id=None, return_url=True) self.set_status.assert_called_with( 'failure', 'There were failures in checks - see ' 'comments by @stsci-bot above', 'stsci-bot', target_url='url')
def test_experimental(self): # Pull request is experimental. Don't check change log yet but # leave a comment. self.changelog_cfg.return_value = True self.labels.return_value = ['Experimental'] expected = ( CHANGELOG_PROLOGUE.format(user='******') + CHANGELOG_NOT_DONE.format( status='an experimental', is_done='discussion in settled') + CHANGELOG_EPILOGUE) with app.app_context(): process_changelog_consistency('repo', '1234', 'installation') assert self.issues.call_count == 0 self.submit_comment.assert_called_with(expected, comment_id=None, return_url=True) self.set_status.assert_called_with( 'failure', 'There were failures in checks - see ' 'comments by @astropy-bot above', 'astropy-bot', target_url='url')