本文整理汇总了Python中lintreview.review.Review类的典型用法代码示例。如果您正苦于以下问题:Python Review类的具体用法?Python Review怎么用?Python Review使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Review类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_publish_summary
def test_publish_summary(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)
problems.set_changes([1])
sha = 'abc123'
review = Review(gh, 3)
review.publish_summary(problems)
assert gh.issues.comments.create.called
eq_(1, gh.issues.comments.create.call_count)
calls = gh.issues.comments.create.call_args_list
msg = """There are 2 errors:
* Console/Command/Task/AssetBuildTask.php, line 117 - Something bad
* Console/Command/Task/AssetBuildTask.php, line 119 - Something bad
"""
expected = call(3, msg)
eq_(calls[0], expected)
示例2: test_filter_existing__removes_duplicates
def test_filter_existing__removes_duplicates(self):
fixture_data = load_fixture('comments_current.json')
self.pr.review_comments.return_value = map(
lambda f: GhIssueComment(f),
json.loads(fixture_data))
problems = Problems()
review = Review(self.gh, 2)
filename_1 = "Routing/Filter/AssetCompressor.php"
filename_2 = "View/Helper/AssetCompressHelper.php"
problems.add(filename_1, 87, 'A pithy remark')
problems.add(filename_1, 87, 'Something different')
problems.add(filename_2, 88, 'I <3 it')
problems.add(filename_2, 89, 'Not such a good comment')
review.load_comments()
review.remove_existing(problems)
res = problems.all(filename_1)
eq_(1, len(res))
expected = Comment(filename_1, 87, 87, 'Something different')
eq_(res[0], expected)
res = problems.all(filename_2)
eq_(1, len(res))
expected = Comment(filename_2, 88, 88, 'I <3 it')
eq_(res[0], expected)
示例3: test_publish_problems
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)
示例4: test_publish_problems_remove_ok_label
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)
示例5: test_filter_existing__removes_duplicates
def test_filter_existing__removes_duplicates(self, http):
fixture_data = load_fixture('comments_current.json')
response = Response()
response._content = fixture_data
http.return_value = response
gh = Github()
problems = Problems()
review = Review(gh, 2)
filename_1 = "Routing/Filter/AssetCompressor.php"
filename_2 = "View/Helper/AssetCompressHelper.php"
problems.add(filename_1, 87, 'A pithy remark')
problems.add(filename_1, 87, 'Something different')
problems.add(filename_2, 88, 'I <3 it')
problems.add(filename_2, 89, 'Not such a good comment')
review.load_comments()
review.remove_existing(problems)
res = problems.all(filename_1)
eq_(1, len(res))
expected = Comment(filename_1, 87, 87, 'Something different')
eq_(res[0], expected)
res = problems.all(filename_2)
eq_(1, len(res))
expected = Comment(filename_2, 88, 88, 'I <3 it')
eq_(res[0], expected)
示例6: test_filter_existing__removes_duplicates
def test_filter_existing__removes_duplicates(self):
fixture_data = load_fixture('comments_current.json')
self.pr.review_comments.return_value = [
GhIssueComment(f, self.session) for f in json.loads(fixture_data)
]
problems = Problems()
review = Review(self.repo, self.pr, self.config)
filename_1 = "Routing/Filter/AssetCompressor.php"
filename_2 = "View/Helper/AssetCompressHelper.php"
problems.add(filename_1, 87, 'A pithy remark')
problems.add(filename_1, 87, 'Something different')
problems.add(filename_2, 88, 'I <3 it')
problems.add(filename_2, 89, 'Not such a good comment')
review.load_comments()
review.remove_existing(problems)
res = problems.all(filename_1)
self.assertEqual(1, len(res))
expected = Comment(filename_1,
87,
87,
'A pithy remark\nSomething different')
self.assertEqual(res[0], expected)
res = problems.all(filename_2)
self.assertEqual(1, len(res))
expected = Comment(filename_2, 88, 88, 'I <3 it')
self.assertEqual(res[0], expected)
示例7: Processor
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)
示例8: test_publish_summary
def test_publish_summary(self):
problems = Problems()
filename_1 = 'Console/Command/Task/AssetBuildTask.php'
errors = (
IssueComment('Terrible things'),
Comment(filename_1, 117, 117, 'Something bad'),
Comment(filename_1, 119, 119, 'Something bad'),
)
problems.add_many(errors)
problems.set_changes([1])
review = Review(self.repo, self.pr, self.config)
review.publish_summary(problems)
assert self.pr.create_comment.called
self.assertEqual(1, self.pr.create_comment.call_count)
msg = """There are 3 errors:
* Terrible things
* Console/Command/Task/AssetBuildTask.php, line 117 - Something bad
* Console/Command/Task/AssetBuildTask.php, line 119 - Something bad
"""
self.pr.create_comment.assert_called_with(msg)
示例9: test_publish_checkrun
def test_publish_checkrun(self):
self.repo.create_checkrun = Mock()
tst_config = build_review_config(fixer_ini,
{'PULLREQUEST_STATUS': True})
problems = Problems()
filename_1 = 'Console/Command/Task/AssetBuildTask.php'
errors = (
Comment(filename_1, 117, 8, 'Something bad'),
Comment(filename_1, 119, 9, 'Something worse'),
)
problems.add_many(errors)
run_id = 42
review = Review(self.repo, self.pr, tst_config)
review.publish_checkrun(problems, run_id)
assert self.repo.update_checkrun.called
self.assertEqual(1, self.repo.update_checkrun.call_count)
assert_checkrun(
self,
self.repo.update_checkrun.call_args,
errors,
run_id)
assert self.repo.create_status.called is False, 'no status required'
示例10: test_publish_empty_comment_add_ok_label
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)
示例11: test_publish_pull_review_remove_ok_label
def test_publish_pull_review_remove_ok_label(self):
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)
tst_config = build_review_config(fixer_ini, {'OK_LABEL': 'No lint'})
review = Review(self.repo, self.pr, tst_config)
sha = 'abc123'
review.publish_pull_review(problems, sha)
assert self.pr.remove_label.called, 'Label should be removed'
assert self.pr.create_review.called, 'Review should be added'
self.assertEqual(1, self.pr.create_review.call_count)
self.pr.remove_label.assert_called_with(tst_config['OK_LABEL'])
assert_review(
self,
self.pr.create_review.call_args,
errors,
sha)
示例12: test_publish_problems_remove_ok_label
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)
示例13: test_publish_status__ok_no_comment_or_label
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'
示例14: test_publish_pull_review__no_comments
def test_publish_pull_review__no_comments(self):
problems = Problems()
sha = 'abc123'
review = Review(self.repo, self.pr, self.config)
review.publish_pull_review(problems, sha)
assert self.pr.create_review.called is False
示例15: test_load_comments__none_active
def test_load_comments__none_active(self):
fixture_data = load_fixture('comments_none_current.json')
self.pr.review_comments.return_value = [GhIssueComment(f) for f in json.loads(fixture_data)]
review = Review(self.gh, 2)
review.load_comments()
eq_(0, len(review.comments("View/Helper/AssetCompressHelper.php")))