test_acl_cds1951625_fix.py 2.11 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):
62
    rex = current.app.reg_institute
63
    assert rex == "Marseille, CPPM|CPPM, Marseille"
64

65
    authors = recordfix.find_authors_by_affiliation(rex, family_name_fr)
66
    assert authors.split(', ') == CPPM_AUTHORS
67 68


LE GAC Renaud's avatar
LE GAC Renaud committed
69 70 71
def test_first_author(record, recordfix):
    assert record.first_author() == "Aaij, Roel"
    assert recordfix.first_author() == "R. Aaij"
72 73


LE GAC Renaud's avatar
LE GAC Renaud committed
74 75
def test_my_authors(recordfix):
    assert recordfix.my_authors.split(', ') == CPPM_AUTHORS
76 77


LE GAC Renaud's avatar
LE GAC Renaud committed
78 79 80
def test_paper_editor(record, recordfix):
    assert record.paper_editor() == "J. Instrum."
    assert recordfix.paper_editor() == "J Instrum"
81 82


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