Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 656ecd86 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Migrate Thesis.

parent 4dc48966
......@@ -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.
"""
......
# -*- 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)
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