test_acl_cds1951625_fix.py 2.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# -*- 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

"""
LE GAC Renaud's avatar
LE GAC Renaud committed
21
import copy
22 23 24
import pytest

from gluon import current
25 26
from harvest_tools import CheckAndFix, family_name_fr, format_author_fr
from invenio_tools import load_record
27 28 29 30 31 32 33 34 35 36 37 38 39

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"]

LE GAC Renaud's avatar
LE GAC Renaud committed
40

41 42
@pytest.fixture(scope="module")
def record():
LE GAC Renaud's avatar
LE GAC Renaud committed
43
    return load_record('cds.cern.ch', 1951625)
44 45


LE GAC Renaud's avatar
LE GAC Renaud committed
46 47 48 49 50
@pytest.fixture(scope="module")
def recordfix(record):
    rec = copy.deepcopy(record)

    svc = CheckAndFix()
51 52 53
    svc.authors(rec)
    svc.format_authors(rec, format_author_fr)
    svc.format_editor(rec)
54
    svc.get_my_authors(rec, cmpFct=family_name_fr)
55 56 57 58 59 60
    svc.submitted(rec)
    svc.year(rec)

    return rec


61
def test_find_authors_by_affiliation(recordfix):
LE GAC Renaud's avatar
LE GAC Renaud committed
62 63 64
    svc = CheckAndFix()
    rex = svc._get_reg_institute()

65 66 67 68 69 70
    references = set(["^CPPM, Marseille",
                      "^Centre de Physique des Particules de Marseille (CPPM)",
                      "^Marseille, CPPM"])

    values = set(rex.split("|"))
    assert values == references
71

72
    authors = recordfix.find_authors_by_affiliation(rex, family_name_fr)
73
    assert authors.split(', ') == CPPM_AUTHORS
74 75


LE GAC Renaud's avatar
LE GAC Renaud committed
76 77 78
def test_first_author(record, recordfix):
    assert record.first_author() == "Aaij, Roel"
    assert recordfix.first_author() == "R. Aaij"
79 80


LE GAC Renaud's avatar
LE GAC Renaud committed
81 82
def test_my_authors(recordfix):
    assert recordfix.my_authors.split(', ') == CPPM_AUTHORS
83 84


LE GAC Renaud's avatar
LE GAC Renaud committed
85 86
def test_paper_editor(record, recordfix):
    assert record.paper_editor() == "J. Instrum."
LE GAC Renaud's avatar
LE GAC Renaud committed
87
    assert recordfix.paper_editor() == "J. Instrum."
88 89


LE GAC Renaud's avatar
LE GAC Renaud committed
90 91 92
def test_submitted(record, recordfix):
    assert record.submitted() == ["01 Oct 2014"]
    assert recordfix.submitted() == ["2014-10-01"]