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
656ecd86
Commit
656ecd86
authored
Jun 29, 2017
by
LE GAC Renaud
Browse files
Migrate Thesis.
parent
4dc48966
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
15 deletions
+76
-15
modules/harvest_tools/thesis.py
modules/harvest_tools/thesis.py
+14
-15
tests/scan/test_Thesis.py
tests/scan/test_Thesis.py
+62
-0
No files found.
modules/harvest_tools/thesis.py
View file @
656ecd86
...
...
@@ -8,7 +8,6 @@ import traceback
from
.automaton
import
Automaton
from
.base
import
MSG_CRASH
,
MSG_LOAD
from
.checkandfix
import
CheckException
from
invenio_tools
import
RecordThesis
from
plugin_dbui
import
get_id
,
UNDEF_ID
...
...
@@ -23,20 +22,25 @@ class Thesis(Automaton):
"""Check the content of the thesis in order to fix non conformities.
Args:
record (RecordThesis): record describing a thesis.
record (RecordThesis):
record describing a thesis.
Returns:
bool: ``False`` when a non conformity is found and can not be
corrected.
bool:
``False`` when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
(
"check thesis record"
)
try
:
self
.
check
.
is_thesis
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
format_universities
(
record
)
self
.
check
.
format_authors
(
record
,
fmt
=
"F. Last"
)
...
...
@@ -51,23 +55,18 @@ class Thesis(Automaton):
print
(
traceback
.
format_exc
())
return
False
if
self
.
dbg
:
print
(
"check thesis record"
)
if
isinstance
(
record
,
RecordThesis
):
return
True
self
.
logs
[
-
1
].
reject
(
MSG_NO_THESIS
,
record
=
record
)
return
False
return
True
def
insert_record
(
self
,
record
):
"""Insert a thesis in the database.
Args:
record (RecordThesis): record describing a thesis.
record (RecordThesis):
record describing a thesis.
Returns:
int: one when the record is inserted / updated in the database
int:
one when the record is inserted / updated in the database
zero otherwise.
"""
...
...
tests/scan/test_Thesis.py
0 → 100644
View file @
656ecd86
# -*- coding: utf-8 -*-
"""test_Thesis
* Harvester is Thesis
* Store is cds.cern.ch
* LHCb PHD for the current year
* Check that all error messages are expected
"""
import
pytest
from
gluon
import
current
from
harvest_tools.thesis
import
Thesis
from
harvest_tools.factory
import
build_harvester_tool
from
test_tools
import
messages
@
pytest
.
fixture
(
scope
=
"module"
)
def
harvester_messages
():
return
messages
()
def
test_lhcb_acl
(
harvester_messages
):
"""Harvest LHCb thesis for a given year.
This test is useful to:
* debug an harvester
* profile its performance to see where the time is spent.
* compare different implementation to measure improvements.
* ...
"""
# These parameter only make sense if you are inserting record in database
# Select the current year in order to test different case
db
=
current
.
db
id_team
=
7
# LHCb
id_project
=
8
# LHCb
id_category
=
16
# PHD
year
=
current
.
request
.
now
.
year
# build the harvester
tool
=
build_harvester_tool
(
db
,
id_team
,
id_project
,
"theses"
,
id_category
,
year_start
=
str
(
year
),
year_end
=
""
,
dry_run
=
True
,
debug
=
True
)
assert
isinstance
(
tool
,
Thesis
)
# run the harvester
tool
.
process_url
(
"cds.cern.ch"
,
"LHCb Theses"
)
# analyse the log
# Number of article cannot be check since it evolve within a year
# Only test that there are no unexpected messages
msgs
=
set
([
el
.
txt
for
el
in
tool
.
logs
])
assert
msgs
.
issubset
(
harvester_messages
)
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