def run(args, config):
    if args.failure is not None:
        ret = mark_pull_request_build_failed(
            args.pr, args.build, args.failure, config)
    else:
        ret = do_merge_pull_request(args.pr, args.build, config)

    print ret
Beispiel #2
0
def run(args, config):
    if args.failure is not None:
        ret = mark_pull_request_build_failed(args.pr, args.build, args.failure,
                                             config)
    else:
        ret = do_merge_pull_request(args.pr, args.build, config)

    print ret
Beispiel #3
0
    def test_merge_pull_request(self):
        # Fake out the data for the github requests.
        pull_request = 5
        build_number = 10
        merged = load_data('github-merge-success.json')
        pulls = load_data('github-open-pulls.json', load_json=True)
        pull_request_data = pulls[0]

        responses.add(
            responses.GET,
            'https://api.github.com/repos/CanonicalJS/juju-gui/pulls/5',
            body=json.dumps(pull_request_data),
            status=200,
            content_type='application/json'
        )
        # Will need to mock out the pull request get, the comment response.
        responses.add(
            responses.PUT,
            'https://api.github.com/repos/CanonicalJS/juju-gui/pulls/5/merge',
            body=merged,
            status=200,
            content_type='application/json'
        )

        fake_config = {
            'github.owner': 'CanonicalJS',
            'github.project': 'juju-gui',
            'github.username': '******',
            'github.token': '1234',
            'jenkins.merge.url': 'http://jenkins/job/{0}/build',
            'jenkins.merge.job': 'juju-gui-merge',
            'jenkins.merge.token': 'buildme',
            'jenkins.merge.trigger': '$$merge$$',
        }

        resp = do_merge_pull_request(
            pull_request,
            build_number,
            fake_config
        )

        self.assertEqual('Pull Request successfully merged', resp)
    def test_merge_pull_request(self):
        # Fake out the data for the github requests.
        pull_request = 5
        build_number = 10
        merged = load_data('github-merge-success.json')
        pulls = load_data('github-open-pulls.json', load_json=True)
        pull_request_data = pulls[0]

        responses.add(
            responses.GET,
            'https://api.github.com/repos/CanonicalJS/juju-gui/pulls/5',
            body=json.dumps(pull_request_data),
            status=200,
            content_type='application/json')
        # Will need to mock out the pull request get, the comment response.
        responses.add(
            responses.PUT,
            'https://api.github.com/repos/CanonicalJS/juju-gui/pulls/5/merge',
            body=merged,
            status=200,
            content_type='application/json')

        fake_config = {
            'github.owner': 'CanonicalJS',
            'github.project': 'juju-gui',
            'github.username': '******',
            'github.token': '1234',
            'jenkins.merge.url': 'http://jenkins/job/{0}/build',
            'jenkins.merge.job': 'juju-gui-merge',
            'jenkins.merge.token': 'buildme',
            'jenkins.merge.trigger': '$$merge$$',
        }

        resp = do_merge_pull_request(pull_request, build_number, fake_config)

        self.assertEqual('Pull Request successfully merged', resp)