test_11_harvest_tools_base.py 1.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
"""test_11_harvest_tools_base

"""
import pytest

from gluon import current
from harvest_tools import (family_name_fr,
                           get_rex_institute,
                           order_oais)
from store_tools import load_record, search_synonym


@pytest.fixture(scope="module")
def reccds():
    return load_record("cds.cern.ch", 1951625)


@pytest.fixture(scope="module")
def recins():
    return load_record("inspirehep.net", 1319638, shelf="literature")


def test_family_name_11001(reccds):
    reccds.check_format_authors(fmt="F. Last")

    authors = reccds.df_authors
    for row in authors.itertuples():
        assert row.last_name == family_name_fr(row.fmt_name)


def test_get_rex_institue_11002():
    val = get_rex_institute(current.db, current.app)
    assert val == \
34 35 36 37
        r"(?:^|\|)Marseille, CPPM(?:$|\|)|" \
        r"(?:^|\|)CPPM, Marseille(?:$|\|)|" \
        r"(?:^|\|)Centre de Physique des Particules de Marseille \(CPPM\)(?:$|\|)|" \
        r"(?:^|\|)Aix Marseille Univ, CNRS/IN2P3, CPPM, Marseille, France(?:$|\|)"
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74


def test_order_oais_11003(reccds, recins):

    assert order_oais(reccds.oai()) == \
        "oai:cds.cern.ch:1951625, oai:inspirehep.net:1319638"

    assert order_oais(recins.oai()) == \
        "oai:cds.cern.ch:1951625, oai:inspirehep.net:1319638"


# ............................................................................
#
# others
#
def test_search_synonym_11030():
    db = current.db

    # collaboration ANTARES, TANAMI (defined as synonym in the db)
    record = load_record("inspirehep.net", 1342250, shelf="literature")

    colid = search_synonym(
        db.collaborations,
        "collaboration",
        record.collaboration())

    assert colid == 2

    # collaboration = ANTARES (defined as synonym in the db))
    record = load_record("inspirehep.net", 718872, shelf="literature")

    colid = search_synonym(
        db.collaborations,
        "collaboration",
        record.collaboration())

    assert colid == 2