test_04_RecordPubli.py 6.07 KB
Newer Older
LE GAC Renaud's avatar
LE GAC Renaud committed
1 2 3 4
"""test_04_RecordPubli

Test all methods of the RecordPubli class for a given article:

5
    https://cds.cern.ch/record/1951625.
LE GAC Renaud's avatar
LE GAC Renaud committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

    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
LE GAC Renaud's avatar
LE GAC Renaud committed
24

25
from store_tools import load_record
26
from store_tools.recordpubli import RecordPubli
LE GAC Renaud's avatar
LE GAC Renaud committed
27 28 29


@pytest.fixture(scope="module")
30
def record():
LE GAC Renaud's avatar
LE GAC Renaud committed
31 32 33
    return load_record("cds.cern.ch", 1951625)


34 35 36 37 38
def test_upcast_cds_04001(record):
    assert isinstance(record, RecordPubli)


def test_constructor_cds_04002(record):
LE GAC Renaud's avatar
LE GAC Renaud committed
39 40 41
    """test the method _process_authors and _process_publication_info.

    """
42
    authors = record["authors"]
LE GAC Renaud's avatar
LE GAC Renaud committed
43 44 45 46 47 48 49 50 51
    assert isinstance(authors, pd.DataFrame)

    refcols = ["affiliation",
               "first_name",
               "fmt_name",
               "full_name",
               "last_name"]

    assert len(authors.columns.difference(refcols)) == 0
52
    assert len(authors) == record["number_of_authors"]
LE GAC Renaud's avatar
LE GAC Renaud committed
53
    assert authors.affiliation.iloc[12] == "INFN, Rome|CERN"
LE GAC Renaud's avatar
LE GAC Renaud committed
54

55
    papers = record["publication_info"]
LE GAC Renaud's avatar
LE GAC Renaud committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

    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
#
71
def test_is_authors_cds_04010(record):
72
    assert record.is_authors()
LE GAC Renaud's avatar
LE GAC Renaud committed
73 74


75
def test_authors_as_list_cds_04011(record):
76
    authors = record.authors_as_list()
LE GAC Renaud's avatar
LE GAC Renaud committed
77

78
    assert len(authors) == record["number_of_authors"]
LE GAC Renaud's avatar
LE GAC Renaud committed
79 80 81 82
    assert authors[0] == "Aaij, Roel"
    assert authors[1] == "Adeva, Bernardo"
    assert authors[344] == "Le Gac, Renaud"
    assert authors[-1] == "Zvyagin, Alexander"
LE GAC Renaud's avatar
LE GAC Renaud committed
83 84


85
def test_first_author_cds_04012(record):
86
    assert record.first_author() == "Aaij, Roel"
LE GAC Renaud's avatar
LE GAC Renaud committed
87 88


89
def test_find_authors_cds_04013(record):
90
    assert record.find_authors("Leo") == \
LE GAC Renaud's avatar
LE GAC Renaud committed
91
        "Beaucourt, Leo, Kravchuk, Leonid, Leo, Sabato"
LE GAC Renaud's avatar
LE GAC Renaud committed
92 93


94
def test_reformat_author_cds_04014(record):
95
    record.reformat_authors("F. Last")
LE GAC Renaud's avatar
LE GAC Renaud committed
96

97
    authors = record.authors_as_list()
LE GAC Renaud's avatar
LE GAC Renaud committed
98

99
    assert len(authors) == record["number_of_authors"]
LE GAC Renaud's avatar
LE GAC Renaud committed
100 101 102 103 104
    assert authors[0] == "R. Aaij"
    assert authors[1] == "B. Adeva"
    assert authors[12] == "A. A. Alves Jr"
    assert authors[344] == "R. Le Gac"
    assert authors[-1] == "A. Zvyagin"
LE GAC Renaud's avatar
LE GAC Renaud committed
105

106
    record.reformat_authors("Last, First")
LE GAC Renaud's avatar
LE GAC Renaud committed
107 108 109 110 111 112


# ............................................................................
#
#    Section devoted to affiliation
#
113
def test_is_affiliations_cds_04020(record):
114 115
    assert record.is_affiliations()
    assert record.is_affiliation_for_all()
LE GAC Renaud's avatar
LE GAC Renaud committed
116 117


118
def test_institutes_cds_04021(record):
LE GAC Renaud's avatar
LE GAC Renaud committed
119

120
    institutes = record.institutes()
LE GAC Renaud's avatar
LE GAC Renaud committed
121 122 123 124 125 126

    assert institutes[0] == "AGH-UST, Cracow"
    assert institutes[44] == "MIT"
    assert institutes[-1] == "Zurich U."


127
def test_find_affiliation_cds_04022(record):
128
    affiliation = record.find_affiliation(r"Marseille, CPPM|CPPM, Marseille")
LE GAC Renaud's avatar
LE GAC Renaud committed
129 130 131 132 133 134 135
    assert affiliation == "Marseille, CPPM"


# ............................................................................
#
#    Section devoted to authors and institutes
#
136
def test_first_author_institutes_cds_04023(record):
137
    assert record.first_author_institutes() == "NIKHEF, Amsterdam"
LE GAC Renaud's avatar
LE GAC Renaud committed
138 139


140
def test_find_authors_by_affiliation_cds_04024(record):
LE GAC Renaud's avatar
LE GAC Renaud committed
141
    pattern = "CPPM, Marseille|Marseille, CPPM"
142
    authors = record.find_authors_by_affiliation(pattern, sep="|")
LE GAC Renaud's avatar
LE GAC Renaud committed
143

LE GAC Renaud's avatar
LE GAC Renaud committed
144 145 146 147 148
    assert authors == "Akar, Simon|Aslanides, Elie|Cogan, Julien|" \
                      "Kanso, Walaa|Le Gac, Renaud|Leroy, Olivier|" \
                      "Mancinelli, Giampiero|Mordà, Alessandro|" \
                      "Perrin-Terrin, Mathieu|Serrano, Justine|" \
                      "Tsaregorodtsev, Andrei"
LE GAC Renaud's avatar
LE GAC Renaud committed
149 150 151 152 153 154


# ............................................................................
#
#    Other methods
#
155
def test_collaboration_cds_04030(record):
156
    assert record.collaboration() == "LHCb Collaboration"
LE GAC Renaud's avatar
LE GAC Renaud committed
157 158


159
def test_is_published_cds_04031(record):
160
    assert record.is_published()
LE GAC Renaud's avatar
LE GAC Renaud committed
161 162


163
def test_is_with_erratum_cds_04032(record):
164
    assert not record.is_with_erratum()
LE GAC Renaud's avatar
LE GAC Renaud committed
165 166


167
def test_paper_info_cds_04033(record):
168 169 170 171
    assert record.paper_editor() == "JINST"
    assert record.paper_pages() == "P12005"
    assert record.paper_volume() == "9"
    assert record.paper_year() == "2014"
LE GAC Renaud's avatar
LE GAC Renaud committed
172

173

174
def test_paper_reference_cds_04034(record):
175
    assert record.paper_reference() == "JINST 9 2014 P12005"
LE GAC Renaud's avatar
LE GAC Renaud committed
176 177


178
def test_preprint_number_cds_04035(record):
179
    assert record.preprint_number() == "arXiv:1410.0149"
180 181


182
def test_paper_url_cds_04036(record):
183
    assert record.paper_url() == \
184
        "http://cds.cern.ch/record/1951625/files/arXiv:1410.0149.pdf"
LE GAC Renaud's avatar
LE GAC Renaud committed
185

186

187
def test_report_number_cds_04037(record):
188
    assert record.report_number() == \
LE GAC Renaud's avatar
LE GAC Renaud committed
189 190
        "CERN-PH-EP-2014-221, LHCB-PAPER-2014-047, LHCB-PAPER-2014-047-003"

191

192
def test_submitted_cds_04038(record):
193
    assert record.submitted() == "01 Oct 2014"
194 195


196
def test_title_cds_04039(record):
197
    assert record.title() == "Precision luminosity measurements at LHCb"
198 199


200
def test_all_cds_042040():
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
    """same article oai:inspirehet.net:1762838 and oai:cds.cern.ch:2698323"""

    rec = load_record("cds.cern.ch", 2698323)

    assert rec.title() == \
        r"Updated measurement of decay-time-dependent CP asymmetries " \
        r"in $D^0 \to K^+K^-$ and $D^0 \to \pi^+\pi^-$ decays"

    assert rec.paper_reference() == "Phys. Rev. D 101 2020 012005"
    assert rec.first_author() == "Aaij, Roel"
    assert rec.primary_oai() == "oai:cds.cern.ch:2698323"
    assert rec.secondary_oai() == "oai:inspirehep.net:1762838"

    assert rec.paper_url() == \
        "http://cds.cern.ch/record/2698323/files/1911.01114.pdf"

    assert rec.preprint_number() == "arXiv:1911.01114"
    assert rec.report_number() == "LHCB-PAPER-2019-032, LHCB-PAPER-2019-032-003"