Beispiel #1
0
def get_pr(source_ref):
    status = ci_get('/status', status_code=200)
    assert 'prs' in status
    assert '_watched_targets' in status
    all_prs = [PR.from_json(x) for x in status['prs']]
    prs = [pr for pr in all_prs if pr.source.ref.name == source_ref]
    assert len(prs) == 1, [str(x.source.ref) for x in all_prs]
    return prs[0]
Beispiel #2
0
def get_pr(source_ref):
    status = ci_get('/status', status_code=200)
    assert 'prs' in status
    assert '_watched_targets' in status
    all_prs = [PR.from_json(x) for x in status['prs']]
    prs = [pr for pr in all_prs if pr.source.ref.name == source_ref]
    assert len(prs) == 1, [str(x.source.ref) for x in all_prs]
    return prs[0]
Beispiel #3
0
def get_pr(source_ref,
           delay_in_seconds=DELAY_IN_SECONDS,
           max_polls=MAX_POLLS):
    polls = 0
    prs = []
    while len(prs) == 0:
        status = ci_get('/status', status_code=200)
        assert 'prs' in status
        assert '_watched_targets' in status
        all_prs = [PR.from_json(x) for x in status['prs']]
        prs = [pr for pr in all_prs if pr.source.ref.name == source_ref]
        polls = polls + 1
        time.sleep(delay_in_seconds)
        assert polls < MAX_POLLS
    assert len(prs) == 1, [str(x.source.ref) for x in all_prs]
    return prs[0]
Beispiel #4
0
def poll_until_pr_exists_and(source_ref,
                             poll_until_true,
                             delay_in_seconds=DELAY_IN_SECONDS,
                             max_polls=MAX_POLLS):
    prs = []
    polls = 0
    while (len(prs) == 0 or not poll_until_true(prs[0])) and polls < max_polls:
        time.sleep(delay_in_seconds)
        status = ci_get('/status', status_code=200)
        assert 'prs' in status
        assert '_watched_targets' in status
        all_prs = [PR.from_json(x) for x in status['prs']]
        prs = [pr for pr in all_prs if pr.source.ref.name == source_ref]
        assert len(prs) <= 1, [str(x.source.ref) for x in all_prs]
        polls = polls + 1
    assert len(prs) == 1
    return prs[0]
Beispiel #5
0
def poll_until_pr_exists_and(source_ref,
                             poll_until_true,
                             delay_in_seconds=DELAY_IN_SECONDS,
                             max_polls=MAX_POLLS):
    prs = []
    polls = 0
    while (len(prs) == 0
           or not poll_until_true(prs[0])) and polls < max_polls:
        time.sleep(delay_in_seconds)
        status = ci_get('/status', status_code=200)
        assert 'prs' in status
        assert '_watched_targets' in status
        all_prs = [PR.from_json(x) for x in status['prs']]
        prs = [pr for pr in all_prs if pr.source.ref.name == source_ref]
        assert len(prs) <= 1, [str(x.source.ref) for x in all_prs]
        polls = polls + 1
    assert len(prs) == 1
    return prs[0]