예제 #1
0
def test_orcids_for_push_orcid_in_author_with_claim(author_in_isolated_app):
    record = {
        "_collections": ["Literature"],
        "authors": [
            {
                "full_name": "No Orcid, Jimmy"
            },
            {
                "full_name": "Smith, John",
                "ids": [{
                    "schema": "INSPIRE BAI",
                    "value": "J.Smith.1"
                }],
                "record": get_record_ref(author_in_isolated_app),
                "curated_relation": True,
            },
        ],
        "document_type": ["article"],
        "titles": [{
            "title": "An interesting paper"
        }],
    }

    assert validate(record, "hep") is None
    assert list(get_orcids_for_push(record)) == ["0000-0002-1825-0097"]
예제 #2
0
def test_orcids_for_push_orcid_in_paper(inspire_app):
    record = {
        "_collections": ["Literature"],
        "authors": [
            {
                "full_name": "No Orcid, Jimmy"
            },
            {
                "full_name":
                "Smith, John",
                "ids": [
                    {
                        "schema": "INSPIRE BAI",
                        "value": "J.Smith.1"
                    },
                    {
                        "schema": "ORCID",
                        "value": "0000-0002-1825-0097"
                    },
                ],
            },
        ],
        "document_type": ["article"],
        "titles": [{
            "title": "An interesting paper"
        }],
    }

    assert validate(record, "hep") is None
    assert list(get_orcids_for_push(record)) == ["0000-0002-1825-0097"]
예제 #3
0
def test_orcids_for_push_no_authors(inspire_app):
    record = {
        "_collections": ["Literature"],
        "corporate_author": ["Corporate Author"],
        "document_type": ["article"],
        "titles": [{
            "title": "A paper with no authors"
        }],
    }

    assert validate(record, "hep") is None
    assert list(get_orcids_for_push(record)) == []
예제 #4
0
def test_orcids_for_push_no_orcids(inspire_app):
    record = {
        "_collections": ["Literature"],
        "authors": [{
            "full_name": "Smith, John",
            "ids": [{
                "schema": "INSPIRE BAI",
                "value": "J.Smith.1"
            }],
        }],
        "document_type": ["article"],
        "titles": [{
            "title": "An interesting paper"
        }],
    }

    assert validate(record, "hep") is None
    assert list(get_orcids_for_push(record)) == []
예제 #5
0
파일: api.py 프로젝트: tsgit/inspirehep
def push_to_orcid(record):
    """If needed, queue the push of the new changes to ORCID."""
    if not current_app.config["FEATURE_FLAG_ENABLE_ORCID_PUSH"]:
        LOGGER.info("ORCID push feature flag not enabled")
        return

    # Ensure there is a control number. This is not always the case because of broken store_record.
    if "control_number" not in record:
        return

    orcids = get_orcids_for_push(record)
    orcids_and_tokens = push_access_tokens.get_access_tokens(orcids)

    kwargs_to_pusher = dict(record_db_version=record.model.version_id)

    for orcid, access_token in orcids_and_tokens:
        _send_push_task(
            kwargs={
                "orcid": orcid,
                "rec_id": record["control_number"],
                "oauth_token": access_token,
                "kwargs_to_pusher": kwargs_to_pusher,
            })