当前位置: 首页>>代码示例>>Python>>正文


Python review.Review类代码示例

本文整理汇总了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)
开发者ID:hutchic,项目名称:lint-review,代码行数:27,代码来源:test_review.py

示例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)
开发者ID:pSub,项目名称:lint-review,代码行数:27,代码来源:test_review.py

示例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)
开发者ID:hutchic,项目名称:lint-review,代码行数:34,代码来源:test_review.py

示例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)
开发者ID:pSub,项目名称:lint-review,代码行数:27,代码来源:test_review.py

示例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)
开发者ID:hutchic,项目名称:lint-review,代码行数:29,代码来源:test_review.py

示例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)
开发者ID:markstory,项目名称:lint-review,代码行数:30,代码来源:test_review.py

示例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)
开发者ID:kevinjqiu,项目名称:lint-review,代码行数:34,代码来源:processor.py

示例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)
开发者ID:markstory,项目名称:lint-review,代码行数:25,代码来源:test_review.py

示例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'
开发者ID:markstory,项目名称:lint-review,代码行数:25,代码来源:test_review.py

示例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)
开发者ID:hutchic,项目名称:lint-review,代码行数:26,代码来源:test_review.py

示例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)
开发者ID:markstory,项目名称:lint-review,代码行数:25,代码来源:test_review.py

示例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)
开发者ID:Ronan-,项目名称:lint-review,代码行数:25,代码来源:test_review.py

示例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'
开发者ID:pSub,项目名称:lint-review,代码行数:8,代码来源:test_review.py

示例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
开发者ID:markstory,项目名称:lint-review,代码行数:8,代码来源:test_review.py

示例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")))
开发者ID:coras-io,项目名称:lint-review,代码行数:8,代码来源:test_review.py


注:本文中的lintreview.review.Review类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。