test_18_check_and_fix_thesis_ins.py 2.24 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
"""test_18_check_and_fix_thesis_ins

    https://inspirehep.net/api/literature/10888032
    (same as https://cds.cern.ch/record/1394605)

    Test individual method of check and fix process for thesis:

        * 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

"""
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", 1088032, shelf="literature")


def test_subtype_18001(record):
    assert record.subtype() == "thesis"


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


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


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

    assert len(authors) == 1
    assert authors[0] == "Khanji, Basem"

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

    assert authors[0] == "B. Khanji"


def test_extract_my_authors_18014(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 == "B. Khanji"


def test_check_submitted_date_18015(record):
    # raise CheckException in case of problem
    assert record.submitted() == ""
    record.check_submitted_date()
    assert record.submitted() == "2011-09-16"