Ejemplo n.º 1
0
def test_get_and_check_single_upstream_artifact_full_path(context):
    folder = os.path.join(context.config['work_dir'], 'cot', 'dependency1')
    os.makedirs(os.path.join(folder, 'public'))
    touch(os.path.join(folder, 'public/file_a'))

    assert get_and_check_single_upstream_artifact_full_path(context, 'dependency1', 'public/file_a') == \
        os.path.join(context.config['work_dir'], 'cot', 'dependency1', 'public', 'file_a')

    with pytest.raises(ScriptWorkerTaskException):
        get_and_check_single_upstream_artifact_full_path(context, 'dependency1', 'public/non_existing_file')

    with pytest.raises(ScriptWorkerTaskException):
        get_and_check_single_upstream_artifact_full_path(context, 'non-existing-dep', 'public/file_a')
Ejemplo n.º 2
0
def test_get_and_check_single_upstream_artifact_full_path(context):
    folder = os.path.join(context.config['work_dir'], 'cot', 'dependency1')
    os.makedirs(os.path.join(folder, 'public'))
    touch(os.path.join(folder, 'public/file_a'))

    assert get_and_check_single_upstream_artifact_full_path(context, 'dependency1', 'public/file_a') == \
        os.path.join(context.config['work_dir'], 'cot', 'dependency1', 'public', 'file_a')

    with pytest.raises(ScriptWorkerTaskException):
        get_and_check_single_upstream_artifact_full_path(context, 'dependency1', 'public/non_existing_file')

    with pytest.raises(ScriptWorkerTaskException):
        get_and_check_single_upstream_artifact_full_path(context, 'non-existing-dep', 'public/file_a')
Ejemplo n.º 3
0
def test_get_and_check_single_upstream_artifact_full_path(context):
    folder = os.path.join(context.config["work_dir"], "cot", "dependency1")
    os.makedirs(os.path.join(folder, "public"))
    touch(os.path.join(folder, "public/file_a"))

    assert get_and_check_single_upstream_artifact_full_path(
        context, "dependency1",
        "public/file_a") == os.path.join(context.config["work_dir"], "cot",
                                         "dependency1", "public", "file_a")

    with pytest.raises(ScriptWorkerTaskException):
        get_and_check_single_upstream_artifact_full_path(
            context, "dependency1", "public/non_existing_file")

    with pytest.raises(ScriptWorkerTaskException):
        get_and_check_single_upstream_artifact_full_path(
            context, "non-existing-dep", "public/file_a")
Ejemplo n.º 4
0
def get_upstream_artifacts(context, preserve_full_paths=False):
    artifacts = {}
    for artifact_dict in context.task["payload"]["upstreamArtifacts"]:
        locale = artifact_dict.get("locale", "en-US")
        artifacts[locale] = artifacts.get(locale, {})
        for path in artifact_dict["paths"]:
            abs_path = scriptworker_artifacts.get_and_check_single_upstream_artifact_full_path(context, artifact_dict["taskId"], path)
            if preserve_full_paths:
                artifacts[locale][path] = abs_path
            else:
                artifacts[locale][os.path.basename(abs_path)] = abs_path
    return artifacts
Ejemplo n.º 5
0
def get_upstream_artifacts(context, preserve_full_paths=False):
    artifacts = {}
    for artifact_dict in context.task['payload']['upstreamArtifacts']:
        locale = artifact_dict.get('locale', 'en-US')
        artifacts[locale] = artifacts.get(locale, {})
        for path in artifact_dict['paths']:
            abs_path = scriptworker_artifacts.get_and_check_single_upstream_artifact_full_path(
                context, artifact_dict['taskId'], path)
            if preserve_full_paths:
                artifacts[locale][path] = abs_path
            else:
                artifacts[locale][os.path.basename(abs_path)] = abs_path
    return artifacts
Ejemplo n.º 6
0
def get_upstream_artifacts_with_zip_extract_param(context):
    # XXX A dict comprehension isn't used because upstream_definition would be erased if the same
    # taskId is present twice in upstreamArtifacts
    upstream_artifacts_per_task_id = {}

    for artifact_definition in context.task['payload']['upstreamArtifacts']:
        task_id = artifact_definition['taskId']
        upstream_definitions = upstream_artifacts_per_task_id.get(task_id, [])

        new_upstream_definition = {
            'paths': [
                scriptworker_artifacts.get_and_check_single_upstream_artifact_full_path(context, task_id, path)
                for path in artifact_definition['paths']
            ],
            'zip_extract': artifact_definition.get('zipExtract', False),
        }

        upstream_definitions.append(new_upstream_definition)
        upstream_artifacts_per_task_id[task_id] = upstream_definitions

    return upstream_artifacts_per_task_id