Пример #1
0
def test_labels_are_created_by_bmu(system, new_pr, bmu_conf, echoserver):
    label.init()
    repo_labels = sorted(label.get_existing_labels(system.github_repo['full_name']))
    proc = echoserver.start(2)
    label_resp = github.sync_request(
        'patch',
        "repos/bmcorser/{0}/issues/{1}".format(
            system.github_repo['name'],
            new_pr['number'],
        ),
        json={'labels': repo_labels[2:4]}
    )
    assert label_resp.ok
    data = echoserver.get_data(proc)
    assert [event['payload']['action'] for event in data] == [
        'labeled',
        'labeled',
    ]
    print(bmu_conf)
    # import ipdb;ipdb.set_trace()
    comment_resp = github.sync_post(
        "repos/bmcorser/{0}/issues/{1}/comments".format(
            system.github_repo['name'],
            new_pr['number'],
        ),
        json={'body': '@bmcorser fff'}
    )
    assert comment_resp.ok
Пример #2
0
def new_pr(system, echoserver):
    name = "branch-{0}".format(uuid.uuid4().hex[:7])
    system.git_run(['fetch', 'origin'])
    system.git_run(['reset', '--hard', 'origin/master'])
    system.git_run(['checkout', '-b', name])
    map(system.local_repo.commit, 'abcde')
    system.git_run(['push', 'origin', name])
    print("Creating PR for {0} on GitHub  ...".format(name))
    proc = echoserver.start(1)
    create_resp = github.sync_post(
        'repos/bmcorser/{0}/pulls'.format(system.github_repo['name']),
        json={
            'title': "PR for {0}".format(name),
            'base': 'master',
            'head': name,
        }
    )
    pr_json = create_resp.json()
    assert echoserver.get_data(proc)[0]['payload']['action'] == 'opened'
    yield pr_json
    print("Closing PR for {0} on GitHub  ...".format(name))
    close_resp = github.sync_request(
        'patch',
        'repos/{0}/{1}/pulls/{2}'.format(
            config.github_user,
            system.github_repo['name'],
            pr_json['number'],
        ),
        json={'state': 'closed'},
    )
    assert close_resp.ok