예제 #1
0
def test_analysis_types(cli_run):
    responses.add(
        responses.GET,
        "https://analysispreservation-dev.cern.ch/api/me",
        json={
            "deposit_groups": [{
                "deposit_group": "atlas-workflows",
                "description": "Create an ATLAS Workflow",
                "name": "ATLAS Workflow"
            }, {
                "deposit_group": "alice-analysis",
                "description": "Create an ALICE Analysis",
                "name": "ALICE Analysis"
            }],
            "email":
            "*****@*****.**",
            "id":
            1
        },
    )

    res = cli_run("analysis types")

    assert res.exit_code == 0
    assert res.stripped_output == json_dumps(
        ["atlas-workflows", "alice-analysis"])
예제 #2
0
def create(api, jsonfile, json, type):
    """Create an analysis."""
    res = api.create(
        data=jsonfile if json is None else json,
        type_=type,
    )

    click.echo(json_dumps(res))
예제 #3
0
def remove(api, pid, field):
    """Remove from analysis metadata."""
    res = api.remove(
        pid=pid,
        field=field,
    )

    click.echo(json_dumps(res))
예제 #4
0
def get(api, pid, with_snapshots):
    """Get all repositories connected with your analysis."""
    res = api.get(
        pid=pid,
        with_snapshots=with_snapshots,
    )

    click.echo(json_dumps(res))
예제 #5
0
def get(api, pid, field):
    """Get analysis metadata."""
    res = api.get(
        pid=pid,
        field=field,
    )

    click.echo(json_dumps(res))
예제 #6
0
def get(api, pid, all):
    """List your draft analysis."""
    if pid:
        res = api.get_draft_by_pid(pid)
    else:
        res = api.get_drafts(all=all)

    click.echo(json_dumps(res))
예제 #7
0
def get_published(api, pid, all):
    """List your published analysis."""
    if pid:
        res = api.get_published_by_pid(pid)
    else:
        res = api.get_published(all=all)

    click.echo(json_dumps(res))
예제 #8
0
def schema(api, analysis_type, version, for_published):
    """Get JSON schema for analysis metadata."""
    res = api.get_schema(
        type_=analysis_type,
        version=version,
        record_schema=for_published,
    )

    click.echo(json_dumps(res))
예제 #9
0
def update(api, pid, json, jsonfile, field):
    """Update analysis metadata."""
    res = api.set(
        pid=pid,
        value=jsonfile if json is None else json,
        field=field,
    )

    click.echo(json_dumps(res))
예제 #10
0
def add(api, pid, rights, user, egroup):
    """Add user/egroup permissions for your analysis."""
    res = api.add(
        pid=pid,
        email=user or egroup,
        rights=rights,
        is_egroup=egroup and True,
    )

    click.echo(json_dumps(res))
예제 #11
0
def update(api, pid, json, jsonfile, text, num, field):
    """Update analysis metadata."""
    value = [
        option for option in [json, jsonfile, text, num] if option is not None
    ][0]

    res = api.set(
        pid=pid,
        value=value,
        field=field,
    )

    click.echo(json_dumps(res))
예제 #12
0
def get_published(api, pid, all, query, search, type, sort, page, size):
    """List your published analysis."""
    if pid:
        res = api.get_published_by_pid(pid)
    else:
        res = api.get_published(all=all,
                                query=query,
                                search=search,
                                type=type,
                                sort=sort,
                                page=page,
                                size=size)

    click.echo(json_dumps(res))
예제 #13
0
def test_analysis_types_when_no_types_for_this_user(cli_run):
    responses.add(
        responses.GET,
        "https://analysispreservation-dev.cern.ch/api/me",
        json={
            "deposit_groups": [],
            "email": "*****@*****.**",
            "id": 1
        },
    )

    res = cli_run("analysis types")

    assert res.exit_code == 0
    assert res.stripped_output == json_dumps([])
예제 #14
0
def types(api):
    """List all types of analysis you can create."""
    res = api.get_schema_types()

    click.echo(json_dumps(res))
예제 #15
0
def get(api, pid):
    """Get list of files attached to analysis with given PID."""
    res = api.get(pid=pid)

    click.echo(json_dumps(res))
예제 #16
0
def get(api, pid):
    """List analysis permissions."""
    res = api.get(pid=pid)

    click.echo(json_dumps(res))