test_acl_cds1951625_fix.py 2.09 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
# -*- coding: utf-8 -*-
"""ARTICLE

    http://cds.cern.ch/record/1951625.

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

The CheckAndFix correction are applied.
Only the changes are checked

Note:
    * The first author is not in the author list
    * LHCb collaboration
    * The publication year is a list (duplicate 773y)
    * The submitted date is not formatted: 01 Oct 2014

"""
import pytest

from helper import load_record
from gluon import current
from harvest_tools import family_name_fr, format_author_fr
from invenio_tools import CheckAndFix

CPPM_AUTHORS = [u"S. Akar",
                u"E. Aslanides",
                u"J. Cogan",
                u"W. Kanso",
                u"R. Le Gac",
                u"O. Leroy",
                u"G. Mancinelli",
                u"A. Mordà",
                u"M. Perrin-Terrin",
                u"J. Serrano",
                u"A. Tsaregorodtsev"]

@pytest.fixture(scope="module")
def record():
    rec = load_record('cds.cern.ch', 1951625)

    # apply all corrections for an article
    svc = CheckAndFix()

    svc.authors(rec)
    svc.format_authors(rec, format_author_fr)
    svc.format_editor(rec)
    svc.my_authors(rec)
    svc.submitted(rec)
    svc.year(rec)

    return rec


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

    assert len(authors) == 704
    assert authors[0] == "R. Aaij"
    assert authors[55] == "M.-O. Bettler"
    assert authors[344] == "R. Le Gac"
    assert authors[-1] == "A. Zvyagin"


def test_find_authors_by_institute(record):
    rex = current.app.reg_institute
    assert rex == "CPPM"

    authors = record.find_authors_by_institute(rex, family_name_fr)
    authors = authors.split(", ")
    assert authors == CPPM_AUTHORS


def test_first_author(record):
    assert record.first_author() == "R. Aaij"


def test_my_authors(record):
    assert record.my_authors.split(', ') == CPPM_AUTHORS


def test_paper_editor(record):
    assert record.paper_editor() == "J Instrum"


def test_submitted(record):
    assert record.submitted() == ["2014-10-01"]