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