本文整理汇总了Python中lintreview.review.Review.publish方法的典型用法代码示例。如果您正苦于以下问题:Python Review.publish方法的具体用法?Python Review.publish怎么用?Python Review.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lintreview.review.Review
的用法示例。
在下文中一共展示了Review.publish方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_publish_empty_comment_add_ok_label
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_empty_comment_add_ok_label(self):
gh = Mock()
problems = Problems(changes=[])
review = Review(gh, 3)
label = config.get('OK_LABEL', 'No lint errors')
with add_ok_label(gh, 3, label):
sha = 'abc123'
review.publish(problems, sha)
assert not gh.pull_requests.comments.create.called
assert gh.issues.comments.create.called
assert gh.issues.labels.remove_from_issue.called
assert_add_to_issue(gh)
calls = gh.issues.labels.remove_from_issue.call_args_list
expected = call(3, label)
eq_(calls, [expected])
calls = gh.issues.comments.create.call_args_list
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
expected = call(3, msg)
eq_(calls[0], expected)
示例2: Processor
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
class Processor(object):
def __init__(self, client, number, head, target_path):
self._client = client
self._number = number
self._head = head
self._target_path = target_path
self._changes = None
self._problems = Problems(target_path)
self._review = Review(client, number)
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._client.pull_requests.list_files(self._number)
pull_request_patches = files.all()
self._changes = DiffCollection(pull_request_patches)
self._problems.set_changes(self._changes)
def run_tools(self, review_config):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
files_to_check = self._changes.get_files(
append_base=self._target_path,
ignore_patterns=review_config.ignore_patterns())
tools.run(
review_config,
self._problems,
files_to_check,
self._target_path)
def publish(self, wait_time=0):
self._problems.limit_to_changes()
self._review.publish(self._problems, self._head, wait_time)
示例3: Processor
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
class Processor(object):
_client = None
_number = None
_head = None
_target_path = None
_changes = None
_problems = None
_review = None
_config = None
def __init__(self, client, number, head, target_path, config=None):
self._client = client
self._number = number
self._head = head
self._target_path = target_path
self._problems = Problems(target_path)
self._review = Review(client, number)
if config is None:
config = {}
self._config = config
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._client.pull_requests.list_files(self._number)
pull_request_patches = files.all()
self._changes = DiffCollection(pull_request_patches)
self._problems.set_changes(self._changes)
def run_tools(self, review_config):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
files_to_check = self._changes.get_files(
append_base=self._target_path,
ignore_patterns=review_config.ignore_patterns())
commits_to_check = self.get_commits(self._number)
tools.run(
review_config,
self._problems,
files_to_check,
commits_to_check,
self._target_path)
def publish(self):
self._problems.limit_to_changes()
self._review.publish(
self._problems,
self._head,
self._config.get('SUMMARY_THRESHOLD'))
def get_commits(self, number):
return self._client.pull_requests.list_commits(number).all()
示例4: test_publish_empty_comment
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_empty_comment(self):
problems = Problems(changes=[])
review = Review(self.gh, 3)
sha = 'abc123'
review.publish(problems, sha)
assert self.issue.create_comment.called, 'Should create a comment'
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
self.issue.create_comment.assert_called_with(msg)
示例5: Processor
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
class Processor(object):
_repository = None
_pull_request = None
_target_path = None
_changes = None
_problems = None
_review = None
_config = None
def __init__(self, repository, pull_request, target_path, config=None):
config = config if config else {}
self._config = config
self._repository = repository
self._pull_request = pull_request
self._target_path = target_path
self._problems = Problems(target_path)
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, review_config):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
files_to_check = self._changes.get_files(
append_base=self._target_path,
ignore_patterns=review_config.ignore_patterns())
commits_to_check = self._pull_request.commits()
log.debug("_problems before tools: %s" % len(self._problems))
self._problems = tools.run(
review_config,
self._problems,
files_to_check,
commits_to_check,
self._target_path)
log.debug("_problems after tools: %s" % len(self._problems))
def publish(self):
self._problems.limit_to_changes()
self._review.publish(
self._problems,
self._pull_request.head,
self._config.get('SUMMARY_THRESHOLD'))
示例6: test_publish_empty_comment_add_ok_label
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_empty_comment_add_ok_label(self):
problems = Problems(changes=[])
config = {'OK_LABEL': 'No lint'}
review = Review(self.repo, self.pr, config)
sha = 'abc123'
review.publish(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(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)
示例7: test_publish_ok_comment
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_ok_comment(self):
gh = Mock()
problems = Problems()
review = Review(gh, 3)
sha = 'abc123'
review.publish(problems, sha)
assert not(gh.pull_requests.comments.create.called)
assert gh.issues.comments.create.called
calls = gh.issues.comments.create.call_args_list
expected = call(3, ':+1: No lint errors found.')
eq_(calls[0], expected)
示例8: test_publish_empty_comment_add_ok_label
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_empty_comment_add_ok_label(self):
problems = Problems(changes=[])
review = Review(self.gh, 3)
label = 'No lint errors'
with add_ok_label(self.gh, 3, review, label):
sha = 'abc123'
review.publish(problems, sha)
assert self.issue.create_comment.called, 'ok comment should be added.'
assert self.issue.remove_label.called, 'label should be removed.'
self.issue.remove_label.assert_called_with(label)
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
self.issue.create_comment.assert_called_with(msg)
示例9: test_publish_empty_comment
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_empty_comment(self):
gh = Mock()
problems = Problems(changes=[])
review = Review(gh, 3)
sha = 'abc123'
review.publish(problems, sha)
assert not(gh.pull_requests.comments.create.called)
assert gh.issues.comments.create.called
calls = gh.issues.comments.create.call_args_list
msg = ('Could not review pull request. '
'It may be too large, or contain no reviewable changes.')
expected = call(3, msg)
eq_(calls[0], expected)
示例10: test_publish_comment_threshold_checks
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_comment_threshold_checks(self):
fixture = load_fixture('comments_current.json')
self.pr.review_comments.return_value = [GhIssueComment(f) for f in json.loads(fixture)]
problems = Problems()
filename_1 = 'Console/Command/Task/AssetBuildTask.php'
errors = (
(filename_1, 117, 'Something bad'),
(filename_1, 119, 'Something bad'),
)
problems.add_many(errors)
problems.set_changes([1])
sha = 'abc123'
review = Review(self.gh, 3)
review.publish_summary = Mock()
review.publish(problems, sha, 1)
assert review.publish_summary.called, 'Should have been called.'
示例11: test_publish_ok_comment_add_ok_label
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_ok_comment_add_ok_label(self):
gh = Mock()
problems = Problems(changes=[1])
review = Review(gh, 3)
label = config.get('OK_LABEL', 'No lint errors')
with add_ok_label(gh, 3, label, create=True):
sha = 'abc123'
review.publish(problems, sha)
assert not gh.pull_requests.comments.create.called
assert not gh.issues.comments.create.called
assert gh.issues.labels.remove_from_issue.called
calls = gh.issues.labels.remove_from_issue.call_args_list
expected = call(3, label)
eq_(calls, [expected])
assert_add_to_issue(gh, 3, label, create=True)
assert not(gh.pull_requests.comments.create.called)
示例12: test_publish_empty_comment_with_comment_status
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_empty_comment_with_comment_status(self):
config = {
'PULLREQUEST_STATUS': True,
}
problems = Problems(changes=[])
review = Review(self.repo, self.pr, config)
sha = 'abc123'
review.publish(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,
'error',
msg)
self.pr.create_comment.assert_called_with(msg)
示例13: test_publish_comment_threshold_checks
# 需要导入模块: from lintreview.review import Review [as 别名]
# 或者: from lintreview.review.Review import publish [as 别名]
def test_publish_comment_threshold_checks(self, http):
fixture_data = load_fixture('comments_current.json')
response = Response()
response._content = fixture_data
http.return_value = response
gh = Github()
problems = Problems()
filename_1 = 'Console/Command/Task/AssetBuildTask.php'
errors = (
(filename_1, 117, 'Something bad'),
(filename_1, 119, 'Something bad'),
)
problems.add_many(errors)
problems.set_changes([1])
sha = 'abc123'
review = Review(gh, 3)
review.publish_summary = Mock()
review.publish(problems, sha, 1)
assert review.publish_summary.called, 'Should have been called.'