예제 #1
0
async def check_treestatus(config, task):
    """Return True if we can land based on treestatus.

    Args:
        config (dict): the running config
        task (dict): the running task

    Returns:
        bool: ``True`` if the tree is open.

    """
    tree = get_short_source_repo(task)
    url = "%s/trees/%s" % (config["treestatus_base_url"], tree)
    path = os.path.join(config["work_dir"], "treestatus.json")
    await retry_async(download_file,
                      args=(url, path),
                      retry_exceptions=(DownloadError, ))

    treestatus = load_json_or_yaml(path, is_path=True)
    if treestatus["result"]["status"] != "closed":
        log.info(
            "treestatus is %s - assuming we can land",
            repr(treestatus["result"]["status"]),
        )
        return True
    return False
예제 #2
0
def test_get_short_source_repo(task_defn):
    assert ttask.get_short_source_repo(task_defn) == "mozilla-test-source"