def test_publish_problems_remove_ok_label(self): problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review = Review(self.gh, 3) label = 'No lint errors' with add_ok_label(self.gh, 3, review, label): sha = 'abc123' review.publish_problems(problems, sha) assert self.issue.remove_label.called, 'Label should be removed' assert self.pr.create_review_comment.called, 'Comments should be added' eq_(2, self.pr.create_review_comment.call_count) self.issue.remove_label.assert_called_with(label) assert_review_comments_created( self.pr.create_review_comment.call_args_list, errors, sha)
def test_publish_problems_remove_ok_label(self): problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' config = {'OK_LABEL': 'No lint'} review = Review(self.repo, self.pr, config) sha = 'abc123' review.publish_problems(problems, sha) assert self.pr.remove_label.called, 'Label should be removed' assert self.pr.create_review_comment.called, 'Comments should be added' eq_(2, self.pr.create_review_comment.call_count) self.pr.remove_label.assert_called_with(config['OK_LABEL']) assert_review_comments_created( self.pr.create_review_comment.call_args_list, errors, sha)
def test_publish_problems(self): gh = Mock() problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review = Review(gh, 3) review.publish_problems(problems, sha) assert gh.pull_requests.comments.create.called eq_(2, gh.pull_requests.comments.create.call_count) calls = gh.pull_requests.comments.create.call_args_list expected = call(3, { 'commit_id': sha, 'path': errors[0][0], 'position': errors[0][1], 'body': errors[0][2] }) eq_(calls[0], expected) expected = call(3, { 'commit_id': sha, 'path': errors[1][0], 'position': errors[1][1], 'body': errors[1][2] }) eq_(calls[1], expected)
def test_publish_problems_remove_ok_label(self): problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' config = {'OK_LABEL': 'No lint'} review = Review(self.repo, self.pr, config) sha = 'abc123' review.publish_problems(problems, sha) assert self.pr.remove_label.called, 'Label should be removed' assert self.pr.create_review_comment.called, 'Comments should be added' eq_(2, self.pr.create_review_comment.call_count) self.pr.remove_label.assert_called_with(config['OK_LABEL']) assert_review_comments_created( self.pr.create_review_comment.call_args_list, errors, sha)
def test_publish_problems_add_ok_label(self): gh = Mock() problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review = Review(gh, 3) label = config.get('OK_LABEL', 'No lint errors') with add_ok_label(gh, 3, label): sha = 'abc123' review.publish_problems(problems, sha) assert gh.issues.labels.remove_from_issue.called assert gh.pull_requests.comments.create.called eq_(2, gh.pull_requests.comments.create.call_count) assert_add_to_issue(gh) calls = gh.issues.labels.remove_from_issue.call_args_list expected = call(3, label) eq_(calls, [expected]) calls = gh.pull_requests.comments.create.call_args_list expected = call(3, { 'commit_id': sha, 'path': errors[0][0], 'position': errors[0][1], 'body': errors[0][2] }) eq_(calls[0], expected) expected = call(3, { 'commit_id': sha, 'path': errors[1][0], 'position': errors[1][1], 'body': errors[1][2] }) eq_(calls[1], expected)
def test_publish_problems(self): problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review = Review(self.repo, self.pr) review.publish_problems(problems, sha) assert self.pr.create_review_comment.called eq_(2, self.pr.create_review_comment.call_count) assert_review_comments_created( self.pr.create_review_comment.call_args_list, errors, sha)
def test_publish_problems(self): problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review = Review(self.gh, 3) review.publish_problems(problems, sha) assert self.pr.create_review_comment.called eq_(2, self.pr.create_review_comment.call_count) assert_review_comments_created( self.pr.create_review_comment.call_args_list, errors, sha)
def test_publish_with__wait_time(self, time): gh = Mock() problems = Problems() review = Review(gh, 3) filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review.publish_problems(problems, sha, 1) assert time.sleep.called eq_(2, time.sleep.call_count) calls = time.sleep.call_args_list expected = call(1) eq_(calls[0], expected) eq_(calls[1], expected)
def test_publish_with__wait_time(self, time): gh = Mock() problems = Problems() review = Review(gh, 3) filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review.publish_problems(problems, sha, 1) assert time.sleep.called eq_(2, time.sleep.call_count) calls = time.sleep.call_args_list expected = call(1) eq_(calls[0], expected) eq_(calls[1], expected)
def test_publish_problems(self): gh = Mock() problems = Problems() filename_1 = 'Console/Command/Task/AssetBuildTask.php' errors = ( (filename_1, 117, 'Something bad'), (filename_1, 119, 'Something bad'), ) problems.add_many(errors) sha = 'abc123' review = Review(gh, 3) review.publish_problems(problems, sha) assert gh.pull_requests.comments.create.called eq_(2, gh.pull_requests.comments.create.call_count) calls = gh.pull_requests.comments.create.call_args_list expected = call( 3, { 'commit_id': sha, 'path': errors[0][0], 'position': errors[0][1], 'body': errors[0][2] }) eq_(calls[0], expected) expected = call( 3, { 'commit_id': sha, 'path': errors[1][0], 'position': errors[1][1], 'body': errors[1][2] }) eq_(calls[1], expected)