本文整理汇总了Python中lintreview.review.Review.publish_review方法的典型用法代码示例。如果您正苦于以下问题:Python Review.publish_review方法的具体用法?Python Review.publish_review怎么用?Python Review.publish_review使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lintreview.review.Review
的用法示例。
在下文中一共展示了Review.publish_review方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_publish_review_empty_comment
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish_review [as 别名]
def test_publish_review_empty_comment(self):
problems = Problems(changes=DiffCollection([]))
review = Review(self.repo, self.pr, self.config)
sha = 'abc123'
review.publish_review(problems, sha)
assert self.pr.create_comment.called, 'Should create a comment'
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
self.pr.create_comment.assert_called_with(msg)
示例2: test_publish_review_empty_comment_add_ok_label
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish_review [as 别名]
def test_publish_review_empty_comment_add_ok_label(self):
problems = Problems(changes=DiffCollection([]))
tst_config = build_review_config(fixer_ini, {'OK_LABEL': 'No lint'})
review = Review(self.repo, self.pr, tst_config)
sha = 'abc123'
review.publish_review(problems, sha)
assert self.pr.create_comment.called, 'ok comment should be added.'
assert self.pr.remove_label.called, 'label should be removed.'
self.pr.remove_label.assert_called_with(tst_config['OK_LABEL'])
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
self.pr.create_comment.assert_called_with(msg)
示例3: test_publish_review_empty_comment_with_comment_status
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish_review [as 别名]
def test_publish_review_empty_comment_with_comment_status(self):
tst_config = build_review_config(fixer_ini,
{'PULLREQUEST_STATUS': True})
problems = Problems(changes=DiffCollection([]))
review = Review(self.repo, self.pr, tst_config)
sha = 'abc123'
review.publish_review(problems, sha)
assert self.pr.create_comment.called, 'Should create a comment'
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
self.repo.create_status.assert_called_with(
self.pr.head,
'success',
msg)
self.pr.create_comment.assert_called_with(msg)
示例4: test_publish_review_no_count_change
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish_review [as 别名]
def test_publish_review_no_count_change(self, pub_status_mock, _):
fixture = load_fixture('comments_current.json')
self.pr.review_comments.return_value = [
GhIssueComment(f, self.session) for f in json.loads(fixture)]
problems = Problems()
# Match the line/positions in comments_current.json
filename_1 = 'Console/Command/Task/AssetBuildTask.php'
errors = (
Comment(filename_1, 40, 40, '2. Something bad'),
Comment(filename_1, 87, 87, '1. Something bad'),
Comment(filename_1, 89, 89, '2. Something bad'),
)
problems.add_many(errors)
problems.set_changes([1])
sha = 'abc123'
tst_config = build_review_config(fixer_ini, {'SUMMARY_THRESHOLD': 1})
review = Review(self.repo, self.pr, tst_config)
review.publish_review(problems, sha)
# Ensure publish_status(True) means the status=failed
pub_status_mock.assert_called_with(True)
示例5: test_publish_review_comment_threshold_checks
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish_review [as 别名]
def test_publish_review_comment_threshold_checks(self):
fixture = load_fixture('comments_current.json')
self.pr.review_comments.return_value = [
GhIssueComment(f, self.session) for f in json.loads(fixture)
]
problems = Problems()
filename_1 = 'Console/Command/Task/AssetBuildTask.php'
errors = (
Comment(filename_1, 117, 117, 'Something bad'),
Comment(filename_1, 119, 119, 'Something bad'),
)
problems.add_many(errors)
problems.set_changes([1])
sha = 'abc123'
tst_config = build_review_config(fixer_ini, {'SUMMARY_THRESHOLD': 1})
review = Review(self.repo, self.pr, tst_config)
with patch('lintreview.review.Review.publish_summary') as pub_sum_mock:
review.publish_review(problems, sha)
self.assertTrue(pub_sum_mock.called)
示例6: Processor
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish_review [as 别名]
class Processor(object):
_repository = None
_pull_request = None
_target_path = None
_changes = None
_review = None
_config = None
problems = None
def __init__(self, repository, pull_request, target_path, config):
self._config = config
self._repository = repository
self._pull_request = pull_request
self._target_path = target_path
self.problems = Problems()
self._review = Review(repository, pull_request, config)
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._pull_request.files()
self._changes = DiffCollection(files)
self.problems.set_changes(self._changes)
def run_tools(self):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
config = self._config
files_to_check = self._changes.get_files(
ignore_patterns=config.ignore_patterns()
)
commits_to_check = self._pull_request.commits()
tool_list = tools.factory(
config,
self.problems,
self._target_path)
if config.fixers_enabled():
self.apply_fixers(tool_list, files_to_check)
tools.run(tool_list, files_to_check, commits_to_check)
def apply_fixers(self, tool_list, files_to_check):
try:
fixer_context = fixers.create_context(
self._config,
self._target_path,
self._repository,
self._pull_request,
)
fixer_diff = fixers.run_fixers(
tool_list,
self._target_path,
files_to_check)
fixers.apply_fixer_diff(
self._changes,
fixer_diff,
fixer_context)
except (ConfigurationError, WorkflowError) as e:
log.info('Fixer application failed. Got %s', e)
message = u'Unable to apply fixers. {}'.format(e)
self.problems.add(InfoComment(message))
except Exception as e:
log.info('Fixer application failed, '
'rolling back working tree. Got %s', e)
fixers.rollback_changes(self._target_path)
def publish(self, check_run_id=None):
self.problems.limit_to_changes()
if check_run_id:
self._review.publish_checkrun(
self.problems,
check_run_id)
else:
self._review.publish_review(
self.problems,
self._pull_request.head)