Example #1
0
async def bouncer_submission(context):
    """Implement the bouncer submission behavior"""
    log.info("Preparing to submit information to bouncer")
    submissions = context.task["payload"]["submission_entries"]

    for product_name, pr_config in submissions.items():
        if await does_product_exist(context, product_name):
            log.warning('Product "{}" already exists. Skipping...'.format(product_name))
        else:
            log.info('Adding product "{}"...'.format(product_name))
            await api_add_product(context, product_name=product_name, add_locales=pr_config["options"]["add_locales"], ssl_only=pr_config["options"]["ssl_only"])
            log.info("Sanity check to ensure product has been successfully added...")
            if not await does_product_exist(context, product_name):
                raise ScriptWorkerTaskException("Bouncer entries are corrupt")

        log.info("Sanity check submission entries before updating ...")
        for platform, path in pr_config["paths_per_bouncer_platform"].items():
            check_path_matches_destination(product_name, path)
        log.info("All submission entries look good before updating them!")

        log.info("Adding corresponding paths ...")
        for platform, path in pr_config["paths_per_bouncer_platform"].items():
            if await does_location_path_exist(context, product_name, platform, path):
                log.warning('Path "{}" for product "{}" already exists. Skipping...'.format(path, product_name))
            else:
                await api_add_location(context, product_name, platform, path)

        log.info("Sanity check to ensure locations have been successfully added...")
        locations_info = await get_locations_info(context, product_name)
        locations_paths = [i["path"] for i in locations_info]
        check_locations_match(locations_paths, pr_config["paths_per_bouncer_platform"])
        log.info("All entries look good, bouncer has been correctly updated!")
Example #2
0
def test_check_locations_match(locations, product_config, raises):
    if raises:
        with pytest.raises(ScriptWorkerTaskException):
            check_locations_match(locations, product_config)
    else:
        check_locations_match(locations, product_config)