def codecov_wait(commit): def check_codecov_job(): r = requests.get( 'https://codecov.io/api/gh/marco-c/gecko-dev/commit/%s' % commit) return True if r.json()['commit']['totals'] is not None else False return utils.wait_until(check_codecov_job, 30) is not None
def get_github_commit(self, mercurial_commit): url = 'https://api.pub.build.mozilla.org/mapper/gecko-dev/rev/hg/%s' def get_commit(): r = requests.get(url % mercurial_commit) if r.status_code == requests.codes.ok: return r.text.split(' ')[0] return None ret = wait_until(get_commit) if ret is None: raise Exception('Mercurial commit is not available yet on mozilla/gecko-dev.') return ret
def test_wait_until(): assert utils.wait_until(lambda: False, 1, 1) is None assert utils.wait_until(lambda: None, 1, 1) is None assert utils.wait_until(lambda: '', 1, 1) is None assert utils.wait_until(lambda: True, 1, 1) is not None assert utils.wait_until(lambda: 'Prova', 1, 1) is not None i = {} def try_twice(): if 'tried' in i: return True else: i['tried'] = True return False assert utils.wait_until(try_twice, 2, 1) is not None
def coveralls_wait(job_url): def check_coveralls_job(): r = requests.get(job_url) return True if r.json()['covered_percent'] else False return utils.wait_until(check_coveralls_job, 60) is not None