Commit 34a60765 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Migrate RecordPubli.

parent cf8a091a
This diff is collapsed.
# -*- coding: utf-8 -*-
"""test_04_RecordPubli
Test all methods of the RecordPubli class for a given article:
http://cds.cern.ch/record/1951625.
(same as http://inspirehep.net/record/1319638)
Precision luminosity measurements at LHCb,
J. Instrum. 9 (2014) P12005
arXiv:1410.0149
704 authors
No correction are applied to the record.
Allow to test the brut force decoding with its mistakes.
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 pandas as pd
import pytest
from invenio_tools import load_record
@pytest.fixture(scope="module")
def reccds():
return load_record("cds.cern.ch", 1951625)
@pytest.fixture(scope="module")
def recins():
return load_record("inspirehep.net", 1319638)
def test_constructor(reccds):
"""test the method _process_authors and _process_publication_info.
"""
authors = reccds["authors"]
assert isinstance(authors, pd.DataFrame)
refcols = ["affiliation",
"first_name",
"fmt_name",
"full_name",
"last_name"]
assert len(authors.columns.difference(refcols)) == 0
assert len(authors) == reccds["number_of_authors"]
assert authors.affiliation.iloc[12] == u"INFN, Rome|CERN"
papers = reccds["publication_info"]
assert isinstance(papers, pd.DataFrame)
assert len(papers) == 1
paper = papers.iloc[0]
assert paper.title == "JINST"
assert paper.volume == "9"
assert paper.year == "2014"
assert paper.pagination == "P12005"
# ............................................................................
#
# Section devoted to authors
#
def test_is_authors(reccds):
assert reccds.is_authors()
def test_authors_as_list(reccds):
authors = reccds.authors_as_list()
assert len(authors) == reccds["number_of_authors"]
assert authors[0] == u"Aaij, Roel"
assert authors[1] == u"Adeva, Bernardo"
assert authors[344] == u"Le Gac, Renaud"
assert authors[-1] == u"Zvyagin, Alexander"
def test_first_author(reccds):
assert reccds.first_author() == u"Aaij, Roel"
def test_find_authors(reccds):
assert reccds.find_authors("Leo") == \
u"Beaucourt, Leo, Kravchuk, Leonid, Leo, Sabato"
def test_reformat_author(reccds):
reccds.reformat_authors("F. Last")
authors = reccds.authors_as_list()
assert authors[0] == u"R. Aaij"
assert authors[1] == u"B. Adeva"
assert authors[12] == u"A. A. Alves Jr"
assert authors[344] == u"R. Le Gac"
assert authors[-1] == u"A. Zvyagin"
reccds.reformat_authors("Last, First")
# ............................................................................
#
# Section devoted to affiliation
#
def test_is_affiliations(reccds):
assert reccds.is_affiliations()
assert reccds.is_affiliation_for_all()
def test_institutes(reccds):
institutes = reccds.institutes()
assert institutes[0] == "AGH-UST, Cracow"
assert institutes[44] == "MIT"
assert institutes[-1] == "Zurich U."
def test_find_affiliation(reccds):
affiliation = reccds.find_affiliation(r"Marseille, CPPM|CPPM, Marseille")
assert affiliation == "Marseille, CPPM"
# ............................................................................
#
# Section devoted to authors and institutes
#
def test_first_author_institutes(reccds):
assert reccds.first_author_institutes() == "NIKHEF, Amsterdam"
def test_find_authors_by_affiliation(reccds):
pattern = "CPPM, Marseille|Marseille, CPPM"
authors = reccds.find_authors_by_affiliation(pattern, sep=u"|")
assert authors == u"Akar, Simon|Aslanides, Elie|Cogan, Julien|" \
u"Kanso, Walaa|Le Gac, Renaud|Leroy, Olivier|" \
u"Mancinelli, Giampiero|Mordà, Alessandro|" \
u"Perrin-Terrin, Mathieu|Serrano, Justine|" \
u"Tsaregorodtsev, Andrei"
# ............................................................................
#
# Other methods
#
def test_collaboration(reccds):
assert reccds.collaboration() == "LHCb Collaboration"
def test_is_published(reccds):
assert reccds.is_published()
def test_is_with_erratum(reccds):
assert not reccds.is_with_erratum()
def test_paper_info(reccds):
assert reccds.paper_editor() == "JINST"
assert reccds.paper_pages() == "P12005"
assert reccds.paper_volume() == "9"
assert reccds.paper_year() == "2014"
def test_paper_reference(reccds):
assert reccds.paper_reference() == "JINST 9 2014 P12005"
def test_preprint_number(reccds, recins):
assert reccds.preprint_number() == "arXiv:1410.0149"
assert recins.preprint_number() == "arXiv:1410.0149"
def test_paper_url(reccds, recins):
assert reccds.paper_url() == "http://arxiv.org/pdf/1410.0149.pdf"
assert recins.paper_url() == \
"http://inspirehep.net/record/1319638/files/arXiv:1410.0149.pdf"
def test_report_number(reccds, recins):
assert reccds.report_number() == \
"CERN-PH-EP-2014-221, LHCB-PAPER-2014-047, LHCB-PAPER-2014-047-003"
assert recins.report_number() == "CERN-PH-EP-2014-221, LHCB-PAPER-2014-047"
def test_submitted(reccds, recins):
assert reccds.submitted() == "01 Oct 2014"
assert recins.submitted() == "2014-10-01"
def test_title(reccds):
assert reccds.title() == "Precision luminosity measurements at LHCb"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment