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
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
limbra
limbra
Commits
4693ac92
Commit
4693ac92
authored
Jan 08, 2021
by
LE GAC Renaud
Browse files
Adapt base method of CheckAndFix
parent
b56f9558
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
15 deletions
+84
-15
modules/harvest_tools/checkandfix.py
modules/harvest_tools/checkandfix.py
+9
-2
tests/basis/test_11_CheckAndFix_base.py
tests/basis/test_11_CheckAndFix_base.py
+75
-13
No files found.
modules/harvest_tools/checkandfix.py
View file @
4693ac92
...
...
@@ -517,6 +517,9 @@ class CheckAndFix(object):
def
is_oai
(
self
,
record
):
"""``True`` when the OAI is not defined in the record.
Note:
make sense only for record from cds.cern.ch or old.inspirehep.net
Args:
record (RecordPubli): record describing a publication.
...
...
@@ -526,6 +529,10 @@ class CheckAndFix(object):
"""
self
.
logger
.
debug
(
f
"
{
T6
}
check is oai"
)
# make no sense for record from new inspirehep.net (March 2020)
if
record
.
host
()
==
"inspirehep.net"
:
return
True
# field / subfield depends on the store
test
=
(
"oai"
in
record
and
"value"
in
record
[
"oai"
])
or
\
(
"FIXME_OAI"
in
record
and
"id"
in
record
[
"FIXME_OAI"
])
...
...
@@ -780,12 +787,12 @@ class CheckAndFix(object):
record
.
reformat_authors
(
fmt_rescue
)
if
sort
:
authors
=
(
record
[
"
authors
"
]
[[
"last_name"
,
"fmt_name"
]]
authors
=
(
record
.
df_
authors
[[
"last_name"
,
"fmt_name"
]]
.
sort_values
(
by
=
"last_name"
)
.
fmt_name
)
else
:
authors
=
(
record
[
"
authors
"
]
.
fmt_name
authors
=
(
record
.
df_
authors
.
fmt_name
.
sort_index
())
# go back to the origin formatting
...
...
tests/basis/test_11_CheckAndFix_base.py
View file @
4693ac92
...
...
@@ -23,6 +23,11 @@ def reccds():
return
load_record
(
"cds.cern.ch"
,
1951625
)
@
pytest
.
fixture
(
scope
=
"module"
)
def
recins
():
return
load_record
(
"inspirehep.net"
,
1319638
,
shelf
=
"literature"
)
@
pytest
.
fixture
(
scope
=
"module"
)
def
svc
():
return
CheckAndFix
()
...
...
@@ -32,18 +37,23 @@ def test_constructor_11001(svc):
assert
svc
.
reg_institute
==
\
r
"(^|\|)Marseille, CPPM($|\|)|"
\
r
"(^|\|)CPPM, Marseille($|\|)|"
\
r
"(^|\|)Centre de Physique des Particules de Marseille \(CPPM\)($|\|)"
r
"(^|\|)Centre de Physique des Particules de Marseille \(CPPM\)($|\|)|"
\
r
"(^|\|)Aix Marseille Univ, CNRS/IN2P3, CPPM, Marseille, France($|\|)"
def
test_is_oai_cds_11002
(
svc
,
reccds
):
# ............................................................................
#
# cds.cern.ch record
#
def
test_is_oai_cds_11010
(
svc
,
reccds
):
assert
svc
.
is_oai
(
reccds
)
def
test_is_bad_oai_cds_110
03
(
svc
,
reccds
):
def
test_is_bad_oai_cds_110
11
(
svc
,
reccds
):
assert
not
svc
.
is_bad_oai_used
(
reccds
)
def
test_temporary_record_cds_110
04
(
svc
,
reccds
):
def
test_temporary_record_cds_110
12
(
svc
,
reccds
):
assert
svc
.
temporary_record
(
reccds
)
is
None
...
...
@@ -61,11 +71,11 @@ def test_temporary_record_cds_11004(svc, reccds):
svc
.
temporary_record
(
recins
)
def
test_authors_cds_110
05
(
svc
,
reccds
):
def
test_authors_cds_110
13
(
svc
,
reccds
):
assert
svc
.
authors
(
reccds
)
is
None
def
test__get_author_rescue_list_cds_110
06
(
svc
,
reccds
):
def
test__get_author_rescue_list_cds_110
14
(
svc
,
reccds
):
assert
svc
.
_get_author_rescue_list
(
reccds
,
8
,
7
)
==
[
"C. Adrover"
,
"S. Akar"
,
"E. Aslanides"
,
...
...
@@ -83,7 +93,7 @@ def test__get_author_rescue_list_cds_11006(svc, reccds):
"A. Tsaregorodtsev"
]
def
test_my_affiliation_cds_110
07
(
svc
,
reccds
):
def
test_my_affiliation_cds_110
15
(
svc
,
reccds
):
assert
svc
.
my_affiliation
(
reccds
,
8
,
7
)
==
"Marseille, CPPM"
# a paper from NA62 -- no CPPM author
...
...
@@ -92,11 +102,66 @@ def test_my_affiliation_cds_11007(svc, reccds):
svc
.
my_affiliation
(
recna62
,
id_project
=
8
,
id_team
=
7
)
def
test_search_synonym_11008
():
def
test_collaboration_cds_11016
(
svc
,
reccds
):
assert
svc
.
collaboration
(
reccds
)
is
None
# ............................................................................
#
# inspirehep.net record (March 2020 onward)
#
def
test_is_oai_ins_11020
(
svc
,
recins
):
assert
svc
.
is_oai
(
recins
)
def
test_is_bad_oai_ins_11021
(
svc
,
recins
):
assert
not
svc
.
is_bad_oai_used
(
recins
)
def
test_authors_ins_11023
(
svc
,
recins
):
assert
svc
.
authors
(
recins
)
is
None
def
test__get_author_rescue_list_ins_11024
(
svc
,
recins
):
assert
svc
.
_get_author_rescue_list
(
recins
,
8
,
7
)
==
[
"C. Adrover"
,
"S. Akar"
,
"E. Aslanides"
,
"J. Cogan"
,
"W. Kanso"
,
"R. Le Gac"
,
"O. Leroy"
,
"G. Mancinelli"
,
"E. Maurice"
,
"A. Morda"
,
"A. Mordà"
,
"M. Perrin-Terrin"
,
"M. Sapunov"
,
"J. Serrano"
,
"A. Tsaregorodtsev"
]
def
test_my_affiliation_ins_11025
(
svc
,
recins
):
assert
svc
.
my_affiliation
(
recins
,
8
,
7
)
==
"Marseille, CPPM"
# a paper from NA62 -- no CPPM author
recna62
=
load_record
(
"cds.cern.ch"
,
1434415
)
with
pytest
.
raises
(
CheckException
):
svc
.
my_affiliation
(
recna62
,
id_project
=
8
,
id_team
=
7
)
def
test_collaboration_ins_11026
(
svc
,
recins
):
assert
svc
.
collaboration
(
recins
)
is
None
# ............................................................................
#
# others
#
def
test_search_synonym_11030
():
db
=
current
.
db
# collaboration ANTARES, TANAMI (defined as synonym in the db)
record
=
load_record
(
"inspirehep.net"
,
1342250
)
record
=
load_record
(
"inspirehep.net"
,
1342250
,
shelf
=
"literature"
)
colid
=
search_synonym
(
db
.
collaborations
,
...
...
@@ -106,7 +171,7 @@ def test_search_synonym_11008():
assert
colid
==
2
# collaboration = ANTARES (defined as synonym in the db))
record
=
load_record
(
"inspirehep.net"
,
718872
)
record
=
load_record
(
"inspirehep.net"
,
718872
,
shelf
=
"literature"
)
colid
=
search_synonym
(
db
.
collaborations
,
...
...
@@ -115,6 +180,3 @@ def test_search_synonym_11008():
assert
colid
==
2
def
test_collaboration_cds_11009
(
svc
,
reccds
):
assert
svc
.
collaboration
(
reccds
)
is
None
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