コード例 #1
0
ファイル: test_newpr.py プロジェクト: jyn514/highfive
    def test_submodule(self):
        handler = HighfiveHandlerMock(Payload({})).handler
        submodule_diff = load_fake('submodule.diff')
        assert handler.modifies_submodule(submodule_diff)

        normal_diff = load_fake('normal.diff')
        assert not handler.modifies_submodule(normal_diff)
コード例 #2
0
ファイル: test_newpr.py プロジェクト: jyn514/highfive
 def make_fakes(cls):
     cls.fakes = {
         'diff': {
             'normal': load_fake('normal.diff'),
             'travis-yml': load_fake('travis-yml.diff'),
         },
         'config': fakes.get_repo_configs(),
         'global_': fakes.get_global_configs(),
     }
コード例 #3
0
    def test_new_pr_contributor_with_labels(self):
        self.mocks['load_json_file'].side_effect = (
            fakes.get_repo_configs()['individuals_no_dirs_labels'],
            fakes.get_global_configs()['base'],
        )
        payload = fakes.Payload.new_pr(repo_owner='rust-lang',
                                       repo_name='rust',
                                       pr_author='pnkfelix')
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                ('GET', 'https://the.url/', None,
                 'application/vnd.github.v3.diff'),
                {
                    'body': fakes.load_fake('normal.diff')
                },
            ),
            (
                ('PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'), {
                    'assignee': 'nrc'
                }),
                {
                    'body': {}
                },
            ),
            (
                ('GET',
                 newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                 None, 'application/vnd.github.cloak-preview'),
                {
                    'body': '{"total_count": 1}'
                },
            ),
            (
                ('POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'), {
                    'body':
                    'r? @nrc\n\n(rust_highfive has picked a reviewer for you, use r? to override)'
                }),
                {
                    'body': {}
                },
            ),
            (
                ('POST', newpr.issue_labels_url % ('rust-lang', 'rust', '7'),
                 ['a', 'b']),
                {
                    'body': {}
                },
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #4
0
    def test_new_pr_contributor_with_labels(self):
        self.mocks['load_json_file'].side_effect = (
            fakes.get_repo_configs()['individuals_no_dirs_labels'],
            fakes.get_global_configs()['base'],
        )
        payload = fakes.Payload.new_pr(
            repo_owner='rust-lang', repo_name='rust', pr_author='pnkfelix'
        )
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                (
                    'GET', 'https://the.url/', None,
                    'application/vnd.github.v3.diff'
                ),
                {'body': fakes.load_fake('normal.diff')},
            ),
            (
                (
                    'PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'),
                    {'assignee': 'nrc'}
                ),
                {'body': {}},
            ),
            (
                (
                    'GET', newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                    None, 'application/vnd.github.cloak-preview'
                ),
                {'body': '{"total_count": 1}'},
            ),
            (
                (
                    'POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'),
                    {'body': 'r? @nrc\n\n(rust_highfive has picked a reviewer for you, use r? to override)'}
                ),
                {'body': {}},
            ),
            (
                (
                    'POST', newpr.issue_labels_url % ('rust-lang', 'rust', '7'),
                    ['a', 'b']
                ),
                {'body': {}},
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #5
0
    def test_new_pr_empty_body(self):
        payload = fakes.Payload.new_pr(
            repo_owner='rust-lang',
            repo_name='rust',
            pr_author='pnkfelix',
            pr_body=None,
        )
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                ('GET', 'https://the.url/', None,
                 'application/vnd.github.v3.diff'),
                {
                    'body': fakes.load_fake('normal.diff')
                },
            ),
            (
                ('PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'), {
                    'assignee': 'nrc'
                }),
                {
                    'body': {}
                },
            ),
            (
                ('GET',
                 newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                 None, 'application/vnd.github.cloak-preview'),
                {
                    'body': '{"total_count": 0}'
                },
            ),
            (
                ('POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'), {
                    'body':
                    "Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon.\n\nIf any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.\n\nPlease see [the contribution instructions](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md) for more information.\n"
                }),
                {
                    'body': {}
                },
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #6
0
    def test_new_pr_empty_body(self):
        payload = fakes.Payload.new_pr(
            repo_owner='rust-lang',
            repo_name='rust',
            pr_author='pnkfelix',
            pr_body=None,
        )
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                ('GET', 'https://the.url/', None,
                 'application/vnd.github.v3.diff'),
                {
                    'body': fakes.load_fake('normal.diff')
                },
            ),
            (
                ('PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'), {
                    'assignee': 'nrc'
                }),
                {
                    'body': {}
                },
            ),
            (
                ('GET',
                 newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                 None, 'application/vnd.github.cloak-preview'),
                {
                    'body': '{"total_count": 0}'
                },
            ),
            (
                ('POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'), {
                    'body':
                    "Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon.\n\nPlease see [the contribution instructions](https://rustc-dev-guide.rust-lang.org/contributing.html) for more information.\n"
                }),
                {
                    'body': {}
                },
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #7
0
    def test_new_pr_contributor(self):
        payload = fakes.Payload.new_pr(repo_owner='rust-lang',
                                       repo_name='rust',
                                       pr_author='pnkfelix')
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                ('GET', 'https://the.url/', None,
                 'application/vnd.github.v3.diff'),
                {
                    'body': fakes.load_fake('normal.diff')
                },
            ),
            (
                ('PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'), {
                    'assignee': 'nrc'
                }),
                {
                    'body': {}
                },
            ),
            (
                ('GET',
                 newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                 None, 'application/vnd.github.cloak-preview'),
                {
                    'body': '{"total_count": 1}'
                },
            ),
            (
                ('POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'), {
                    'body':
                    'r? @nrc\n\n(rust_highfive has picked a reviewer for you, use r? to override)'
                }),
                {
                    'body': {}
                },
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #8
0
    def test_new_pr_empty_body(self):
        payload = fakes.Payload.new_pr(
            repo_owner='rust-lang', repo_name='rust', pr_author='pnkfelix',
            pr_body=None,
        )
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                (
                    'GET', 'https://the.url/', None,
                    'application/vnd.github.v3.diff'
                ),
                {'body': fakes.load_fake('normal.diff')},
            ),
            (
                (
                    'PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'),
                    {'assignee': 'nrc'}
                ),
                {'body': {}},
            ),
            (
                (
                    'GET', newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                    None, 'application/vnd.github.cloak-preview'
                ),
                {'body': '{"total_count": 0}'},
            ),
            (
                (
                    'POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'),
                    {'body': "Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon.\n\nIf any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.\n\nPlease see [the contribution instructions](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md) for more information.\n"}
                ),
                {'body': {}},
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #9
0
    def test_new_pr_contributor(self):
        payload = fakes.Payload.new_pr(
            repo_owner='rust-lang', repo_name='rust', pr_author='pnkfelix'
        )
        handler = newpr.HighfiveHandler(payload, dummy_config())

        api_req_mock = ApiReqMocker([
            (
                (
                    'GET', 'https://the.url/', None,
                    'application/vnd.github.v3.diff'
                ),
                {'body': fakes.load_fake('normal.diff')},
            ),
            (
                (
                    'PATCH', newpr.issue_url % ('rust-lang', 'rust', '7'),
                    {'assignee': 'nrc'}
                ),
                {'body': {}},
            ),
            (
                (
                    'GET', newpr.commit_search_url % ('rust-lang', 'rust', 'pnkfelix'),
                    None, 'application/vnd.github.cloak-preview'
                ),
                {'body': '{"total_count": 1}'},
            ),
            (
                (
                    'POST', newpr.post_comment_url % ('rust-lang', 'rust', '7'),
                    {'body': 'r? @nrc\n\n(rust_highfive has picked a reviewer for you, use r? to override)'}
                ),
                {'body': {}},
            ),
        ])
        handler.new_pr()

        api_req_mock.verify_calls()
コード例 #10
0
ファイル: test_payload.py プロジェクト: yaahc/highfive
 def make_payload(cls):
     cls.payload = Payload(json.loads(load_fake('open-pr.payload')))
コード例 #11
0
ファイル: test_payload.py プロジェクト: nrc/highfive
 def make_payload(cls):
     cls.payload = Payload(json.loads(load_fake('open-pr.payload')))