Commit eb81fae3 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Polish test_02_factory_tools and test_04_RecordPubli

parent fbfbf763
......@@ -7,7 +7,8 @@
"""
from store_tools.base import (is_conference,
is_institute,
is_thesis)
is_thesis,
to_initial)
from store_tools.factory import (add_conference_data,
build_record,
......@@ -233,3 +234,18 @@ def test_thesis_cds_02013():
record = build_record(recjson)
assert isinstance(record, RecordThesis)
# ............................................................................
#
# Author manipulation
#
def test_to_initial_02014():
assert to_initial("Albert") == "A."
assert to_initial("Antonio Augusto") == "A. A."
assert to_initial("Kristof Antoon M") == "K. A. M."
assert to_initial("Jean-Pierre") == "J.-P."
assert to_initial("Marie-Hélène") == "M.-H."
assert to_initial("Marie - Pierre") == "M.-P."
......@@ -23,19 +23,18 @@ import pandas as pd
import pytest
from store_tools import load_record
from store_tools.recordpubli import to_initial
@pytest.fixture(scope="module")
def reccds():
def record():
return load_record("cds.cern.ch", 1951625)
def test_constructor_cds_04001(reccds):
def test_constructor_cds_04001(record):
"""test the method _process_authors and _process_publication_info.
"""
authors = reccds["authors"]
authors = record["authors"]
assert isinstance(authors, pd.DataFrame)
refcols = ["affiliation",
......@@ -45,10 +44,10 @@ def test_constructor_cds_04001(reccds):
"last_name"]
assert len(authors.columns.difference(refcols)) == 0
assert len(authors) == reccds["number_of_authors"]
assert len(authors) == record["number_of_authors"]
assert authors.affiliation.iloc[12] == "INFN, Rome|CERN"
papers = reccds["publication_info"]
papers = record["publication_info"]
assert isinstance(papers, pd.DataFrame)
assert len(papers) == 1
......@@ -60,78 +59,68 @@ def test_constructor_cds_04001(reccds):
assert paper.pagination == "P12005"
def test_to_initial_04002():
assert to_initial("Albert") == "A."
assert to_initial("Antonio Augusto") == "A. A."
assert to_initial("Kristof Antoon M") == "K. A. M."
assert to_initial("Jean-Pierre") == "J.-P."
assert to_initial("Marie-Hélène") == "M.-H."
assert to_initial("Marie - Pierre") == "M.-P."
# ............................................................................
#
# Section devoted to authors
#
def test_is_authors_cds_04003(reccds):
assert reccds.is_authors()
def test_is_authors_cds_04002(record):
assert record.is_authors()
def test_authors_as_list_cds_04004(reccds):
authors = reccds.authors_as_list()
def test_authors_as_list_cds_04003(record):
authors = record.authors_as_list()
assert len(authors) == reccds["number_of_authors"]
assert len(authors) == record["number_of_authors"]
assert authors[0] == "Aaij, Roel"
assert authors[1] == "Adeva, Bernardo"
assert authors[344] == "Le Gac, Renaud"
assert authors[-1] == "Zvyagin, Alexander"
def test_first_author_cds_04005(reccds):
assert reccds.first_author() == "Aaij, Roel"
def test_first_author_cds_04004(record):
assert record.first_author() == "Aaij, Roel"
def test_find_authors_cds_04006(reccds):
assert reccds.find_authors("Leo") == \
def test_find_authors_cds_04005(record):
assert record.find_authors("Leo") == \
"Beaucourt, Leo, Kravchuk, Leonid, Leo, Sabato"
def test_reformat_author_cds_04007(reccds):
reccds.reformat_authors("F. Last")
def test_reformat_author_cds_04006(record):
record.reformat_authors("F. Last")
authors = reccds.authors_as_list()
authors = record.authors_as_list()
assert len(authors) == reccds["number_of_authors"]
assert len(authors) == record["number_of_authors"]
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"
reccds.reformat_authors("Last, First")
record.reformat_authors("Last, First")
# ............................................................................
#
# Section devoted to affiliation
#
def test_is_affiliations_cds_04008(reccds):
assert reccds.is_affiliations()
assert reccds.is_affiliation_for_all()
def test_is_affiliations_cds_04007(record):
assert record.is_affiliations()
assert record.is_affiliation_for_all()
def test_institutes_cds_04009(reccds):
def test_institutes_cds_04008(record):
institutes = reccds.institutes()
institutes = record.institutes()
assert institutes[0] == "AGH-UST, Cracow"
assert institutes[44] == "MIT"
assert institutes[-1] == "Zurich U."
def test_find_affiliation_cds_04010(reccds):
affiliation = reccds.find_affiliation(r"Marseille, CPPM|CPPM, Marseille")
def test_find_affiliation_cds_04009(record):
affiliation = record.find_affiliation(r"Marseille, CPPM|CPPM, Marseille")
assert affiliation == "Marseille, CPPM"
......@@ -139,13 +128,13 @@ def test_find_affiliation_cds_04010(reccds):
#
# Section devoted to authors and institutes
#
def test_first_author_institutes_cds_04011(reccds):
assert reccds.first_author_institutes() == "NIKHEF, Amsterdam"
def test_first_author_institutes_cds_04010(record):
assert record.first_author_institutes() == "NIKHEF, Amsterdam"
def test_find_authors_by_affiliation_cds_04012(reccds):
def test_find_authors_by_affiliation_cds_04011(record):
pattern = "CPPM, Marseille|Marseille, CPPM"
authors = reccds.find_authors_by_affiliation(pattern, sep="|")
authors = record.find_authors_by_affiliation(pattern, sep="|")
assert authors == "Akar, Simon|Aslanides, Elie|Cogan, Julien|" \
"Kanso, Walaa|Le Gac, Renaud|Leroy, Olivier|" \
......@@ -158,52 +147,52 @@ def test_find_authors_by_affiliation_cds_04012(reccds):
#
# Other methods
#
def test_collaboration_cds_04013(reccds):
assert reccds.collaboration() == "LHCb Collaboration"
def test_collaboration_cds_04012(record):
assert record.collaboration() == "LHCb Collaboration"
def test_is_published_cds_04014(reccds):
assert reccds.is_published()
def test_is_published_cds_04013(record):
assert record.is_published()
def test_is_with_erratum_cds_04015(reccds):
assert not reccds.is_with_erratum()
def test_is_with_erratum_cds_04014(record):
assert not record.is_with_erratum()
def test_paper_info_cds_04016(reccds):
assert reccds.paper_editor() == "JINST"
assert reccds.paper_pages() == "P12005"
assert reccds.paper_volume() == "9"
assert reccds.paper_year() == "2014"
def test_paper_info_cds_04015(record):
assert record.paper_editor() == "JINST"
assert record.paper_pages() == "P12005"
assert record.paper_volume() == "9"
assert record.paper_year() == "2014"
def test_paper_reference_cds_04018(reccds):
assert reccds.paper_reference() == "JINST 9 2014 P12005"
def test_paper_reference_cds_04016(record):
assert record.paper_reference() == "JINST 9 2014 P12005"
def test_preprint_number_cds_04019(reccds):
assert reccds.preprint_number() == "arXiv:1410.0149"
def test_preprint_number_cds_04017(record):
assert record.preprint_number() == "arXiv:1410.0149"
def test_paper_url_cds_04021(reccds):
assert reccds.paper_url() == \
def test_paper_url_cds_04018(record):
assert record.paper_url() == \
"http://cds.cern.ch/record/1951625/files/arXiv:1410.0149.pdf"
def test_report_number_cds_04023(reccds):
assert reccds.report_number() == \
def test_report_number_cds_04019(record):
assert record.report_number() == \
"CERN-PH-EP-2014-221, LHCB-PAPER-2014-047, LHCB-PAPER-2014-047-003"
def test_submitted_cds_04025(reccds):
assert reccds.submitted() == "01 Oct 2014"
def test_submitted_cds_04020(record):
assert record.submitted() == "01 Oct 2014"
def test_title_cds_04027(reccds):
assert reccds.title() == "Precision luminosity measurements at LHCb"
def test_title_cds_04021(record):
assert record.title() == "Precision luminosity measurements at LHCb"
def test_all_cds_042028():
def test_all_cds_042022():
"""same article oai:inspirehet.net:1762838 and oai:cds.cern.ch:2698323"""
rec = load_record("cds.cern.ch", 2698323)
......
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