Commit 5a665e1a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Migrate Reports.

parent be6ae624
......@@ -21,10 +21,12 @@ class Reports(Automaton):
"""Check the content of the report in order to fix non conformities.
Args:
record (RecordPubli): record describing a report.
record (RecordPubli):
record describing a report.
Returns:
bool: ``False`` when a non conformity is found and can not be
bool:
``False`` when a non conformity is found and can not be
corrected.
"""
......@@ -40,7 +42,6 @@ class Reports(Automaton):
try:
self.check.submitted(record)
self.check.year(record)
self.check.format_authors(record, fmt="F. Last")
self.check.get_my_authors(record, sort=True)
......@@ -60,11 +61,13 @@ class Reports(Automaton):
"""Insert a report in the database.
Args:
record (RecordPubli): record describing a report.
record (RecordPubli):
record describing a report.
Returns:
int: one when the record is inserted / updated in the database
zero otherwise.
int:
one when the record is inserted / updated in the database
zero otherwise.
"""
db = self.db
......@@ -75,7 +78,7 @@ class Reports(Automaton):
id_status = UNDEF_ID
oai_url = record.oai_url()
title = record.title()
year = record.year()
year = record.submitted()[0:4]
# allow undefined institute authors
try:
......
# -*- coding: utf-8 -*-
"""test_Report
* Harvester is Preprints
* Store is cds.cern.ch
* LHCb AP for the current year
* Check that all error messages are expected
"""
import pytest
from gluon import current
from harvest_tools.reports import Reports
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_ap(harvester_messages):
"""Harvest LHCb report 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 = 14 # AP
year = current.request.now.year
# build the harvester
tool = build_harvester_tool(
db,
id_team,
id_project,
"reports",
id_category,
year_start=str(year),
year_end="",
dry_run=True,
debug=True)
assert isinstance(tool, Reports)
# run the harvester
tool.process_url("cds.cern.ch", "LHCb Reports")
# analyse the log
# Number of talk 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