test_02_Record.py 2.66 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 34 35 36 37 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
# -*- coding: utf-8 -*-
"""test_instantiate_Record

    * Test functions to introspect the type of record.
    * Test functions to upcast the Record from the JSON object.

"""
from invenio_tools.base import is_conference, is_institute, is_thesis
from invenio_tools.factory import build_record
from invenio_tools.inveniostore import InvenioStore
from invenio_tools.recordconf import RecordConf
from invenio_tools.recordinst import RecordInst
from invenio_tools.recordpubli import RecordPubli
from invenio_tools.recordthesis import RecordThesis


def test_conference_cds():

    store = InvenioStore("cds.cern.ch")
    recjson = store.get_record(1411352)

    assert is_conference(recjson)
    assert not is_institute(recjson)
    assert not is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordConf)


def test_conference_inspirehep():

    store = InvenioStore("inspirehep.net")
    recjson = store.get_record(1276938)

    assert is_conference(recjson)
    assert not is_institute(recjson)
    assert not is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordConf)


def test_institute():
    """CPPM"""
    store = InvenioStore("inspirehep.net")
    recjson = store.get_record(902989)

    assert not is_conference(recjson)
    assert is_institute(recjson)
    assert not is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordInst)


def test_publi_cds():
    """Precision luminosity measurements at LHCb"""

    store = InvenioStore("cds.cern.ch")
    recjson = store.get_record(1951625)

    assert not is_conference(recjson)
    assert not is_institute(recjson)
    assert not is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordPubli)


def test_publi_inspirehep():
    """Precision luminosity measurements at LHCb"""

    store = InvenioStore("inspirehep.net")
    recjson = store.get_record(1319638)

    assert not is_conference(recjson)
    assert not is_institute(recjson)
    assert not is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordPubli)


def test_talk_cds():

    store = InvenioStore("cds.cern.ch")
    recjson = store.get_record(2239092)

    assert is_conference(recjson)
    assert not is_institute(recjson)
    assert not is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordConf)

def test_thesis_cds():

    store = InvenioStore("cds.cern.ch")
    recjson = store.get_record(1632177)

    assert not is_conference(recjson)
    assert not is_institute(recjson)
    assert is_thesis(recjson)

    record = build_record(recjson)
    assert isinstance(record, RecordThesis)