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
Exemple #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
    def test_mark_pull_request_build_failed(self):
        # Fake out the data for the github requests.
        pull_request = 5
        build_number = 10
        pulls = load_data('github-open-pulls.json', load_json=True)
        comment = load_data('github-new-issue-comment.json', load_json=True)
        pull_data = pulls[0]

        # Will need to mock out the pull request get, the comment response.
        responses.add(
            responses.GET,
            'https://api.github.com/repos/CanonicalJS/juju-gui/pulls/5',
            body=json.dumps(pull_data),
            status=200,
            content_type='application/json'
        )
        responses.add(
            responses.POST,
            (
                u'https://api.github.com/repos/CanonicalJS/juju-gui/issues/5/'
                u'comments'
            ),
            body=json.dumps(comment),
            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 = mark_pull_request_build_failed(
            pull_request,
            build_number,
            'build Failed',
            fake_config
        )

        self.assertTrue(resp.startswith('https://api.github.com'))
    def test_mark_pull_request_build_failed(self):
        # Fake out the data for the github requests.
        pull_request = 5
        build_number = 10
        pulls = load_data('github-open-pulls.json', load_json=True)
        comment = load_data('github-new-issue-comment.json', load_json=True)
        pull_data = pulls[0]

        # Will need to mock out the pull request get, the comment response.
        responses.add(
            responses.GET,
            'https://api.github.com/repos/CanonicalJS/juju-gui/pulls/5',
            body=json.dumps(pull_data),
            status=200,
            content_type='application/json')
        responses.add(
            responses.POST,
            (u'https://api.github.com/repos/CanonicalJS/juju-gui/issues/5/'
             u'comments'),
            body=json.dumps(comment),
            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 = mark_pull_request_build_failed(pull_request, build_number,
                                              'build Failed', fake_config)

        self.assertTrue(resp.startswith('https://api.github.com'))