test_15_check_and_fix_proceeding_cds.py 3.55 KB
Newer Older
1 2
"""test_15_check_and_fix_proceeding_cds

3 4
    https://cds.cern.ch/record/1411352
    (same as https://inspirehep.net/api/literature/1089237)
5

6
    Test individual method of check and fix process for proceeding:
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

        * 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 CheckException, load_record


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


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


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


def test_check_my_affiliation_15011(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_15012(record):
    assert record.collaboration() == ""
    record.check_collaboration(current.db)
    assert record.collaboration() == ""


def test_check_format_authors_15013(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_15014(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_15015(record):
    # raise CheckException in case of problem
    assert record.submitted() == "05 Jan 2012"
    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_15020(record):
    assert record.conference_country() == "Italy"
    assert record.check_country(current.db) is None


def test_check_conference_date_cds_15021(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_15022(record):
    assert record.paper_editor() == "J. Phys.: Conf. Ser."
    assert record.paper_volume() == "335"

    record.format_editor()

112
    assert record.paper_editor() == "J. Phys. Conf. Ser."
113 114 115 116 117
    assert record.paper_volume() == "335"


def test_check_publisher_15023(record):
    # raise CheckException in case of problem
118
    assert record.check_publisher(current.db) is None
119 120 121


def test_check_paper_reference_15024(record):
122 123
    record.format_editor()
    assert record.paper_reference() == "J. Phys. Conf. Ser. 335 2011 012042"