def test_publish_status__ok_no_comment_or_label(self): config = {'OK_COMMENT': None, 'OK_LABEL': None} review = Review(self.gh, 3, config) review.publish_status(0) assert self.gh.create_status.called, 'Create status not called' assert not self.issue.create_comment.called, 'Comment not created' assert not self.issue.add_labels.called, 'Label added created'
def test_publish_status__ok_no_comment_label_or_status(self): config = { 'OK_COMMENT': None, 'OK_LABEL': None, 'PULLREQUEST_STATUS': False, } review = Review(self.repo, self.pr, config) review.publish_status(0) assert not self.repo.create_status.called, 'Create status called' assert not self.pr.create_comment.called, 'Comment not created' assert not self.pr.add_label.called, 'Label added created'
def test_publish_status__ok_no_comment_or_label(self): app_config = { 'OK_COMMENT': None, 'OK_LABEL': None, 'PULLREQUEST_STATUS': False, } tst_config = build_review_config(fixer_ini, app_config) review = Review(self.repo, self.pr, tst_config) review.publish_status(False) assert self.repo.create_status.called, 'Create status called' assert not self.pr.create_comment.called, 'Comment not created' assert not self.pr.add_label.called, 'Label added created'
def test_publish_status__ok_with_comment_and_label(self): config = {'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors'} review = Review(self.repo, self.pr, config) review.publish_status(0) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with( self.pr.head, 'success', 'No lint errors found.') assert self.pr.create_comment.called, 'Issue comment created' self.pr.create_comment.assert_called_with('Great job!') assert self.pr.add_label.called, 'Label added created' self.pr.add_label.assert_called_with('No lint errors')
def test_publish_status__has_errors(self): config = { 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'APP_NAME': 'custom-name' } review = Review(self.repo, self.pr, config) review.publish_status(1) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with( self.pr.head, 'failure', 'Lint errors found, see pull request comments.') assert not self.pr.create_comment.called, 'Comment not created' assert not self.pr.add_label.called, 'Label added created'
def test_publish_status__ok_with_comment_and_label(self): config = {'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors'} review = Review(self.gh, 3, config) review.publish_status(0) assert self.gh.create_status.called, 'Create status not called' self.gh.create_status.assert_called_with( self.pr.head.sha, 'success', None, 'No lint errors found.', 'lintreview') assert self.issue.create_comment.called, 'Issue comment created' self.issue.create_comment.assert_called_with('Great job!') assert self.issue.add_labels.called, 'Label added created' self.issue.add_labels.assert_called_with('No lint errors')
def test_publish_status__has_errors(self): app_config = { 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'APP_NAME': 'custom-name' } config = build_review_config(fixer_ini, app_config) review = Review(self.repo, self.pr, config) review.publish_status(True) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with( self.pr.head, 'failure', 'Lint errors found, see pull request comments.') assert not self.pr.create_comment.called, 'Comment not created' assert not self.pr.add_label.called, 'Label added created'
def test_publish_status__ok_with_comment_label_and_status(self): config = { 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'PULLREQUEST_STATUS': True, } review = Review(self.repo, self.pr, config) review.publish_status(0) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with(self.pr.head, 'success', 'No lint errors found.') assert self.pr.create_comment.called, 'Issue comment created' self.pr.create_comment.assert_called_with('Great job!') assert self.pr.add_label.called, 'Label added created' self.pr.add_label.assert_called_with('No lint errors')
def test_publish_status__has_errors__success_status(self): app_config = { 'PULLREQUEST_STATUS': False, 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'APP_NAME': 'custom-name' } config = build_review_config(fixer_ini, app_config) eq_('success', config.failed_review_status(), 'config object changed') review = Review(self.repo, self.pr, config) review.publish_status(True) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with( self.pr.head, 'success', 'Lint errors found, see pull request comments.') assert not self.pr.create_comment.called, 'Comment not created' assert not self.pr.add_label.called, 'Label added created'
def test_publish_status__has_errors(self): config = { 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'APP_NAME': 'custom-name' } review = Review(self.gh, 3, config) review.publish_status(1) assert self.gh.create_status.called, 'Create status not called' self.gh.create_status.assert_called_with( self.pr.head.sha, 'failure', None, 'Lint errors found, see pull request comments.', config['APP_NAME']) assert not self.issue.create_comment.called, 'Comment not created' assert not self.issue.add_labels.called, 'Label added created'
def test_publish_status__has_errors__success_status(self): app_config = { 'PULLREQUEST_STATUS': False, 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'APP_NAME': 'custom-name' } tst_config = build_review_config(fixer_ini, app_config) self.assertEqual('success', tst_config.failed_review_status(), 'config object changed') review = Review(self.repo, self.pr, tst_config) review.publish_status(True) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with( self.pr.head, 'success', 'Lint errors found, see pull request comments.') assert not self.pr.create_comment.called, 'Comment not created' assert not self.pr.add_label.called, 'Label added created'
def test_publish_status__ok_with_comment_label(self): app_config = { 'OK_COMMENT': 'Great job!', 'OK_LABEL': 'No lint errors', 'PULLREQUEST_STATUS': True, } tst_config = build_review_config(fixer_ini, app_config) Review(self.repo, self.pr, tst_config) review = Review(self.repo, self.pr, tst_config) review.publish_status(False) assert self.repo.create_status.called, 'Create status not called' self.repo.create_status.assert_called_with( self.pr.head, 'success', 'No lint errors found.') assert self.pr.create_comment.called, 'Issue comment created' self.pr.create_comment.assert_called_with('Great job!') assert self.pr.add_label.called, 'Label added created' self.pr.add_label.assert_called_with('No lint errors')