test_16_check_and_fix_proceeding_ins.py 3.83 KB
Newer Older
1 2
"""test_16_check_and_fix_proceeding_ins

3 4
    https://inspirehep.net/api/literature/1089237
    (same as https://cds.cern.ch/record/1411352)
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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

    Test individual method of check and fix process for article:

        * publication is a published proceeding
        * is with authors form my institute
        * standardise name of collaboration
        * format authors according to my format
        * extract authors form my institute signing the publication
        * is submitted date well formed

        * check country is known in the database
        * check that conference_date is well formed
        * format editor according to my criteria
        * resolve published synonym
        * check reference paper

"""
import pytest

from gluon import current
from harvest_tools import get_rex_institute
from store_tools import load_record


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


def test_subtype_16001(record):
    assert record.subtype() == "proceeding"


# ............................................................................
#
# Check and fix implemented in the RecordCdsConf
#
def test_check_authors_16010(record):
    # raise CheckException in case of problem
    assert record.check_authors() is None


def test_check_my_affiliation_16011(record):
    # raise CheckException in case of problem
    rex_institute = get_rex_institute(current.db, current.app)
    assert record.check_my_affiliation(rex_institute) is None


def test_check_collaboration_16012(record):
    assert record.collaboration() == "LHCb"
    record.check_collaboration(current.db)
    assert record.collaboration() == "LHCb Collaboration"


def test_check_format_authors_16013(record):
    authors = record.authors_as_list()

    assert len(authors) == 1
    assert authors[0] == "Leroy, Olivier"

    record.check_format_authors(fmt="F. Last")
    authors = record.authors_as_list()

    assert authors[0] == "O. Leroy"


def test_extract_my_authors_16014(record):
    # raise CheckException in case of problem
    rex_institute = get_rex_institute(current.db, current.app)
    assert record.my_authors is None

    record.check_format_authors(fmt="F. Last")
    assert record.extract_my_authors(rex_institute, sep="|", sort=True) is None

    my_authors = record.my_authors
    assert my_authors == "O. Leroy"


def test_check_submitted_date_16015(record):
    # raise CheckException in case of problem
    assert record.submitted() == "2011"
    assert record.check_submitted_date() is None
    assert record.submitted() == "2010-12-06"


# ............................................................................
#
# Check and fix implemented in the Proceeding Automaton
#
def test_check_country_16020(record):
    assert record.conference_country() == "Italy"
    assert record.check_country(current.db) is None


def test_check_conference_date_cds_16021(record):

    assert record.conference_dates() == "6-11 Dec 2010"
    record.check_conference_date()
    assert record.conference_dates() == "6-11 Dec 2010"


def test_format_editor_16022(record):
    assert record.paper_editor() == "J. Phys. Conf. Ser."
    assert record.paper_volume() == "335"

    record.format_editor()

    assert record.paper_editor() == "J. Phys. Conf. Ser."
    assert record.paper_volume() == "335"


def test_check_publisher_16023(record):
    # raise CheckException in case of problem
    assert record.check_publisher(current.db) is None
    assert record.paper_editor() == "J. Phys. Conf. Ser."
    assert record.paper_volume() == "335"


def test_check_paper_reference_16024(record):
    # check_paper_reference is a dummy method to preserve interface
    assert record.paper_reference() == "J. Phys. Conf. Ser. 335 2011 012042"
    assert record.check_paper_reference() is None
    assert record.paper_reference() == "J. Phys. Conf. Ser. 335 2011 012042"