Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
eb81fae3
Commit
eb81fae3
authored
Jan 07, 2021
by
LE GAC Renaud
Browse files
Polish test_02_factory_tools and test_04_RecordPubli
parent
fbfbf763
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
66 deletions
+71
-66
tests/basis/test_02_factory_tools.py
tests/basis/test_02_factory_tools.py
+17
-1
tests/basis/test_04_RecordPubli.py
tests/basis/test_04_RecordPubli.py
+54
-65
No files found.
tests/basis/test_02_factory_tools.py
View file @
eb81fae3
...
...
@@ -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."
tests/basis/test_04_RecordPubli.py
View file @
eb81fae3
...
...
@@ -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
rec
cds
():
def
rec
ord
():
return
load_record
(
"cds.cern.ch"
,
1951625
)
def
test_constructor_cds_04001
(
rec
cds
):
def
test_constructor_cds_04001
(
rec
ord
):
"""test the method _process_authors and _process_publication_info.
"""
authors
=
rec
cds
[
"authors"
]
authors
=
rec
ord
[
"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
)
==
rec
cds
[
"number_of_authors"
]
assert
len
(
authors
)
==
rec
ord
[
"number_of_authors"
]
assert
authors
.
affiliation
.
iloc
[
12
]
==
"INFN, Rome|CERN"
papers
=
rec
cds
[
"publication_info"
]
papers
=
rec
ord
[
"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_0400
3
(
rec
cds
):
assert
rec
cds
.
is_authors
()
def
test_is_authors_cds_0400
2
(
rec
ord
):
assert
rec
ord
.
is_authors
()
def
test_authors_as_list_cds_0400
4
(
rec
cds
):
authors
=
rec
cds
.
authors_as_list
()
def
test_authors_as_list_cds_0400
3
(
rec
ord
):
authors
=
rec
ord
.
authors_as_list
()
assert
len
(
authors
)
==
rec
cds
[
"number_of_authors"
]
assert
len
(
authors
)
==
rec
ord
[
"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_0400
5
(
rec
cds
):
assert
rec
cds
.
first_author
()
==
"Aaij, Roel"
def
test_first_author_cds_0400
4
(
rec
ord
):
assert
rec
ord
.
first_author
()
==
"Aaij, Roel"
def
test_find_authors_cds_0400
6
(
rec
cds
):
assert
rec
cds
.
find_authors
(
"Leo"
)
==
\
def
test_find_authors_cds_0400
5
(
rec
ord
):
assert
rec
ord
.
find_authors
(
"Leo"
)
==
\
"Beaucourt, Leo, Kravchuk, Leonid, Leo, Sabato"
def
test_reformat_author_cds_0400
7
(
rec
cds
):
rec
cds
.
reformat_authors
(
"F. Last"
)
def
test_reformat_author_cds_0400
6
(
rec
ord
):
rec
ord
.
reformat_authors
(
"F. Last"
)
authors
=
rec
cds
.
authors_as_list
()
authors
=
rec
ord
.
authors_as_list
()
assert
len
(
authors
)
==
rec
cds
[
"number_of_authors"
]
assert
len
(
authors
)
==
rec
ord
[
"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"
rec
cds
.
reformat_authors
(
"Last, First"
)
rec
ord
.
reformat_authors
(
"Last, First"
)
# ............................................................................
#
# Section devoted to affiliation
#
def
test_is_affiliations_cds_0400
8
(
rec
cds
):
assert
rec
cds
.
is_affiliations
()
assert
rec
cds
.
is_affiliation_for_all
()
def
test_is_affiliations_cds_0400
7
(
rec
ord
):
assert
rec
ord
.
is_affiliations
()
assert
rec
ord
.
is_affiliation_for_all
()
def
test_institutes_cds_0400
9
(
rec
cds
):
def
test_institutes_cds_0400
8
(
rec
ord
):
institutes
=
rec
cds
.
institutes
()
institutes
=
rec
ord
.
institutes
()
assert
institutes
[
0
]
==
"AGH-UST, Cracow"
assert
institutes
[
44
]
==
"MIT"
assert
institutes
[
-
1
]
==
"Zurich U."
def
test_find_affiliation_cds_040
1
0
(
rec
cds
):
affiliation
=
rec
cds
.
find_affiliation
(
r
"Marseille, CPPM|CPPM, Marseille"
)
def
test_find_affiliation_cds_0400
9
(
rec
ord
):
affiliation
=
rec
ord
.
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_0401
1
(
rec
cds
):
assert
rec
cds
.
first_author_institutes
()
==
"NIKHEF, Amsterdam"
def
test_first_author_institutes_cds_0401
0
(
rec
ord
):
assert
rec
ord
.
first_author_institutes
()
==
"NIKHEF, Amsterdam"
def
test_find_authors_by_affiliation_cds_0401
2
(
rec
cds
):
def
test_find_authors_by_affiliation_cds_0401
1
(
rec
ord
):
pattern
=
"CPPM, Marseille|Marseille, CPPM"
authors
=
rec
cds
.
find_authors_by_affiliation
(
pattern
,
sep
=
"|"
)
authors
=
rec
ord
.
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_0401
3
(
rec
cds
):
assert
rec
cds
.
collaboration
()
==
"LHCb Collaboration"
def
test_collaboration_cds_0401
2
(
rec
ord
):
assert
rec
ord
.
collaboration
()
==
"LHCb Collaboration"
def
test_is_published_cds_0401
4
(
rec
cds
):
assert
rec
cds
.
is_published
()
def
test_is_published_cds_0401
3
(
rec
ord
):
assert
rec
ord
.
is_published
()
def
test_is_with_erratum_cds_0401
5
(
rec
cds
):
assert
not
rec
cds
.
is_with_erratum
()
def
test_is_with_erratum_cds_0401
4
(
rec
ord
):
assert
not
rec
ord
.
is_with_erratum
()
def
test_paper_info_cds_0401
6
(
rec
cds
):
assert
rec
cds
.
paper_editor
()
==
"JINST"
assert
rec
cds
.
paper_pages
()
==
"P12005"
assert
rec
cds
.
paper_volume
()
==
"9"
assert
rec
cds
.
paper_year
()
==
"2014"
def
test_paper_info_cds_0401
5
(
rec
ord
):
assert
rec
ord
.
paper_editor
()
==
"JINST"
assert
rec
ord
.
paper_pages
()
==
"P12005"
assert
rec
ord
.
paper_volume
()
==
"9"
assert
rec
ord
.
paper_year
()
==
"2014"
def
test_paper_reference_cds_0401
8
(
rec
cds
):
assert
rec
cds
.
paper_reference
()
==
"JINST 9 2014 P12005"
def
test_paper_reference_cds_0401
6
(
rec
ord
):
assert
rec
ord
.
paper_reference
()
==
"JINST 9 2014 P12005"
def
test_preprint_number_cds_0401
9
(
rec
cds
):
assert
rec
cds
.
preprint_number
()
==
"arXiv:1410.0149"
def
test_preprint_number_cds_0401
7
(
rec
ord
):
assert
rec
ord
.
preprint_number
()
==
"arXiv:1410.0149"
def
test_paper_url_cds_040
2
1
(
rec
cds
):
assert
rec
cds
.
paper_url
()
==
\
def
test_paper_url_cds_0401
8
(
rec
ord
):
assert
rec
ord
.
paper_url
()
==
\
"http://cds.cern.ch/record/1951625/files/arXiv:1410.0149.pdf"
def
test_report_number_cds_040
23
(
rec
cds
):
assert
rec
cds
.
report_number
()
==
\
def
test_report_number_cds_040
19
(
rec
ord
):
assert
rec
ord
.
report_number
()
==
\
"CERN-PH-EP-2014-221, LHCB-PAPER-2014-047, LHCB-PAPER-2014-047-003"
def
test_submitted_cds_0402
5
(
rec
cds
):
assert
rec
cds
.
submitted
()
==
"01 Oct 2014"
def
test_submitted_cds_0402
0
(
rec
ord
):
assert
rec
ord
.
submitted
()
==
"01 Oct 2014"
def
test_title_cds_0402
7
(
rec
cds
):
assert
rec
cds
.
title
()
==
"Precision luminosity measurements at LHCb"
def
test_title_cds_0402
1
(
rec
ord
):
assert
rec
ord
.
title
()
==
"Precision luminosity measurements at LHCb"
def
test_all_cds_04202
8
():
def
test_all_cds_04202
2
():
"""same article oai:inspirehet.net:1762838 and oai:cds.cern.ch:2698323"""
rec
=
load_record
(
"cds.cern.ch"
,
2698323
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment