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
03615868
Commit
03615868
authored
Apr 16, 2020
by
LE GAC Renaud
Browse files
Update tests/basis
parent
0300a974
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
21 deletions
+20
-21
modules/harvest_tools/checkandfix.py
modules/harvest_tools/checkandfix.py
+5
-7
modules/invenio_tools/factory.py
modules/invenio_tools/factory.py
+4
-3
tests/basis/test_01_InvenioStore.py
tests/basis/test_01_InvenioStore.py
+1
-1
tests/basis/test_03_Record.py
tests/basis/test_03_Record.py
+1
-1
tests/basis/test_04_RecordPubli.py
tests/basis/test_04_RecordPubli.py
+3
-3
tests/basis/test_05_RecordConf.py
tests/basis/test_05_RecordConf.py
+1
-1
tests/basis/test_07_RecordInst.py
tests/basis/test_07_RecordInst.py
+2
-2
tests/basis/test_08_CheckAndFix_base.py
tests/basis/test_08_CheckAndFix_base.py
+1
-1
tests/basis/test_10_CheckAndFix_article.py
tests/basis/test_10_CheckAndFix_article.py
+1
-1
tests/basis/test_11_CheckAndFix_proceeding.py
tests/basis/test_11_CheckAndFix_proceeding.py
+1
-1
No files found.
modules/harvest_tools/checkandfix.py
View file @
03615868
...
...
@@ -21,7 +21,6 @@ from invenio_tools.recordpubli import PAPER_REFERENCE_KEYS
from
plugin_dbui
import
CLEAN_SPACES
,
get_id
,
UNDEF_ID
DECODE_ARXIV
=
re
.
compile
(
r
"arXiv:(\d{2})(\d{2})\."
)
# Decode submitted date: DD MMM YYYY or DD MM YYY
...
...
@@ -79,6 +78,7 @@ class CheckAndFix(object):
"""A collection of tools to check and repair the content of record.
"""
def
__init__
(
self
):
self
.
db
=
current
.
db
...
...
@@ -118,13 +118,11 @@ class CheckAndFix(object):
# CDS has the opening and closing dates encoded as 20141231
if
"opening_date"
in
meeting
and
"closing_date"
in
meeting
:
fmt
=
"%Y%m%d"
val
=
meeting
[
"opening_date"
].
replace
(
"-"
,
""
)
opening
=
datetime
.
strptime
(
val
,
"%Y%m%d"
)
val
=
meeting
[
"opening_date"
]
opening
=
datetime
.
strptime
(
val
,
fmt
)
val
=
meeting
[
"closing_date"
]
closing
=
datetime
.
strptime
(
val
,
fmt
)
val
=
meeting
[
"closing_date"
].
replace
(
"-"
,
""
)
closing
=
datetime
.
strptime
(
val
,
"%Y%m%d"
)
return
(
opening
,
closing
)
...
...
modules/invenio_tools/factory.py
View file @
03615868
...
...
@@ -158,16 +158,17 @@ def add_conference_data(recjson):
de
=
datetime
.
strptime
(
end
,
"%Y-%m-%d"
)
if
ds
.
month
==
de
.
month
:
sdate
=
f
"
{
ds
.
day
:
02
}
-
{
de
.
day
:
02
}
"
+
ds
.
strftime
(
"%b %Y"
)
sdate
=
f
"
{
ds
.
day
}
-
{
de
.
day
}
"
+
ds
.
strftime
(
"%b %Y"
)
else
:
sdate
=
f
"
{
ds
.
strftime
(
'%d %b'
)
}
-
{
de
.
strftime
(
'%d %b %Y'
)
}
"
sdate
=
f
"
{
ds
.
strftime
(
'%
-
d %b'
)
}
-
{
de
.
strftime
(
'%
-
d %b %Y'
)
}
"
recjson
[
"meeting_name"
]
=
[{
"closing_date"
:
end
,
"coference_code"
:
confjson
[
"cnum"
],
"country"
:
address
[
"country_code"
],
"date"
:
sdate
,
"location"
:
f
"
{
address
[
'country'
]
}
,
{
address
[
'cities'
][
0
]
}
"
,
"location"
:
f
"
{
address
[
'cities'
][
0
]
}
,
{
address
[
'country'
]
}
"
,
"meeting"
:
confjson
[
"titles"
][
0
][
"title"
],
"opening_date"
:
start
,
"year"
:
confjson
[
"opening_date"
][:
4
]}]
...
...
tests/basis/test_01_InvenioStore.py
View file @
03615868
...
...
@@ -11,7 +11,7 @@ from invenio_tools.inveniostore import InvenioStore
def
test_constructor_exception_01001
():
with
pytest
.
raises
(
CdsException
):
InvenioStore
(
"
cds.cern.ch"
,
shelf
=
"literature
"
)
InvenioStore
(
"
inspirehep"
,
shelf
=
"foo
"
)
def
test_get_ids_cds_01002
():
...
...
tests/basis/test_03_Record.py
View file @
03615868
...
...
@@ -26,7 +26,7 @@ def reccds():
@
pytest
.
fixture
(
scope
=
"module"
)
def
recins
():
store
=
InvenioStore
(
"inspirehep.net"
)
store
=
InvenioStore
(
"inspirehep.net"
,
shelf
=
"literature"
)
recjson
=
store
.
get_record
(
1319638
)
return
Record
(
recjson
)
...
...
tests/basis/test_04_RecordPubli.py
View file @
03615868
...
...
@@ -35,7 +35,7 @@ def reccds():
@
pytest
.
fixture
(
scope
=
"module"
)
def
recins
():
return
load_record
(
"inspirehep.net"
,
1319638
)
return
load_record
(
"inspirehep.net"
,
1319638
,
shelf
=
"literature"
)
def
test_constructor_cds_04001
(
reccds
):
...
...
@@ -210,7 +210,7 @@ def test_paper_url_cds_04021(reccds):
def
test_paper_url_ins_04022
(
recins
):
assert
recins
.
paper_url
()
==
\
"http://inspirehep.net/record/1319638/files/arXiv:1410.0149.pdf"
"http://
old.
inspirehep.net/record/1319638/files/arXiv:1410.0149.pdf"
def
test_report_number_cds_04023
(
reccds
):
...
...
@@ -249,7 +249,7 @@ def test_all_ins_042028():
assert
rec
.
secondary_oai
()
==
"oai:cds.cern.ch:2698323"
assert
rec
.
paper_url
()
==
\
"http://inspirehep.net/record/1762838/files/1911.01114.pdf"
"http://
old.
inspirehep.net/record/1762838/files/1911.01114.pdf"
assert
rec
.
preprint_number
()
==
"arXiv:1911.01114"
assert
rec
.
report_number
()
==
"CERN-EP-2019-225, LHCb-PAPER-2019-032"
...
...
tests/basis/test_05_RecordConf.py
View file @
03615868
...
...
@@ -31,7 +31,7 @@ def reccds():
@
pytest
.
fixture
(
scope
=
"module"
)
def
recins
():
return
load_record
(
"inspirehep.net"
,
1089237
)
return
load_record
(
"inspirehep.net"
,
1089237
,
shelf
=
"literature"
)
def
test_conference_location_cds_05001
(
reccds
):
...
...
tests/basis/test_07_RecordInst.py
View file @
03615868
...
...
@@ -11,7 +11,7 @@ from invenio_tools import load_record, RecordException, RecordInst
@
pytest
.
fixture
(
scope
=
"module"
)
def
record
():
return
load_record
(
"inspirehep.net"
,
902989
)
return
load_record
(
"inspirehep.net"
,
902989
,
shelf
=
"institutions"
)
def
test_exception_host_ins_07001
():
...
...
@@ -21,7 +21,7 @@ def test_exception_host_ins_07001():
def
test_exception_record_ins_07002
():
record
=
load_record
(
"inspirehep.net"
,
1319638
)
record
=
load_record
(
"inspirehep.net"
,
1319638
,
shelf
=
"institutions"
)
with
pytest
.
raises
(
RecordException
):
RecordInst
(
record
)
...
...
tests/basis/test_08_CheckAndFix_base.py
View file @
03615868
...
...
@@ -53,7 +53,7 @@ def test_temporary_record_cds_08004(svc, reccds):
# get a list of recids
payload
=
{
"p"
:
"500__a:'*Temporary record*'"
,
"of"
:
"id"
,
"rg"
:
10
}
r
=
requests
.
get
(
"https://inspirehep.net/search"
,
params
=
payload
)
r
=
requests
.
get
(
"https://
old.
inspirehep.net/search"
,
params
=
payload
)
li
=
r
.
json
()
# try with the oldest one to avoid issue with missing information, etc.
...
...
tests/basis/test_10_CheckAndFix_article.py
View file @
03615868
...
...
@@ -25,7 +25,7 @@ def reccds():
@
pytest
.
fixture
(
scope
=
"module"
)
def
recins
():
return
load_record
(
"inspirehep.net"
,
1509922
)
return
load_record
(
"inspirehep.net"
,
1509922
,
shelf
=
"literature"
)
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
tests/basis/test_11_CheckAndFix_proceeding.py
View file @
03615868
...
...
@@ -31,7 +31,7 @@ def reccds():
@
pytest
.
fixture
(
scope
=
"module"
)
def
recins
():
return
load_record
(
"inspirehep.net"
,
1089237
)
return
load_record
(
"inspirehep.net"
,
1089237
,
shelf
=
"literature"
)
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
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