test_03_Record.py 2.22 KB
Newer Older
LE GAC Renaud's avatar
LE GAC Renaud committed
1 2 3 4
"""test_03_Record

Test all methods of the Record class for a given article:

5 6
    https://cds.cern.ch/record/1951625.
    (same as https://inspirehep.net/record/1319638)
LE GAC Renaud's avatar
LE GAC Renaud committed
7 8 9 10 11 12 13 14

    Precision luminosity measurements at LHCb,
    J. Instrum. 9 (2014) P12005
    arXiv:1410.0149
    704 authors

"""
import pytest
LE GAC Renaud's avatar
LE GAC Renaud committed
15

16
from store_tools.factory import build_store
17
from store_tools.record import Record
LE GAC Renaud's avatar
LE GAC Renaud committed
18 19 20 21


@pytest.fixture(scope="module")
def reccds():
22
    store = build_store("cds.cern.ch")
23 24
    recjson = store.get_record(1951625)
    return Record(recjson)
LE GAC Renaud's avatar
LE GAC Renaud committed
25 26 27 28


@pytest.fixture(scope="module")
def recins():
29
    store = build_store("inspirehep.net", shelf="literature")
30 31
    recjson = store.get_record(1319638)
    return Record(recjson)
LE GAC Renaud's avatar
LE GAC Renaud committed
32 33


LE GAC Renaud's avatar
LE GAC Renaud committed
34
def test__get_cds_03001(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
35 36 37 38 39 40 41 42
    assert reccds._get("subject", "source") == "arXiv"
    assert reccds._get("subject", "source", force_list=True) == ["arXiv"]

    authors = reccds._get("authors", "full_name")
    assert isinstance(authors, list)
    assert len(authors) == reccds["number_of_authors"]


LE GAC Renaud's avatar
LE GAC Renaud committed
43
def test__oai_url_cds_03002(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
44 45 46 47
    oai = reccds["oai"]["value"]
    assert reccds._oai_url(oai) == "http://cds.cern.ch/record/1951625"


LE GAC Renaud's avatar
LE GAC Renaud committed
48
def test_id_cds_03003(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
49 50 51
    assert reccds.id() == 1951625


LE GAC Renaud's avatar
LE GAC Renaud committed
52
def test_primary_oai_cds_03004(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
53 54 55
    assert reccds.primary_oai() == "oai:cds.cern.ch:1951625"


LE GAC Renaud's avatar
LE GAC Renaud committed
56 57
def test_primary_oai_ins_03005(recins):
    assert recins.primary_oai() == "oai:inspirehep.net:1319638"
LE GAC Renaud's avatar
LE GAC Renaud committed
58 59


LE GAC Renaud's avatar
LE GAC Renaud committed
60
def test_oai_03006(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
61 62 63
    assert reccds.oai() == \
        "oai:cds.cern.ch:1951625, oai:inspirehep.net:1319638"

LE GAC Renaud's avatar
LE GAC Renaud committed
64 65

def test_oai_ins_03007(reccds, recins):
LE GAC Renaud's avatar
LE GAC Renaud committed
66 67 68 69
    assert recins.oai() == \
        "oai:inspirehep.net:1319638, oai:cds.cern.ch:1951625"


LE GAC Renaud's avatar
LE GAC Renaud committed
70
def test_primary_oai_url_cds_03008(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
71 72 73
    assert reccds.primary_oai_url() == "http://cds.cern.ch/record/1951625"


LE GAC Renaud's avatar
LE GAC Renaud committed
74
def test_secondary_oai_url_cds_03009(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
75 76 77
    assert reccds.secondary_oai_url() == "http://inspirehep.net/record/1319638"


LE GAC Renaud's avatar
LE GAC Renaud committed
78
def test_oai_url_cds_03010(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
79 80 81 82 83
    assert reccds.oai_url() == \
        "http://cds.cern.ch/record/1951625, " \
        "http://inspirehep.net/record/1319638"


LE GAC Renaud's avatar
LE GAC Renaud committed
84
def test_host_cds_03011(reccds):
LE GAC Renaud's avatar
LE GAC Renaud committed
85
    assert reccds.host() == "cds.cern.ch"
LE GAC Renaud's avatar
LE GAC Renaud committed
86 87 88


def test_host_ins_03012(recins):
LE GAC Renaud's avatar
LE GAC Renaud committed
89
    assert recins.host() == "inspirehep.net"