Commit 80ec86f1 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add more tests for Automaton.

parent bdc7651b
......@@ -532,6 +532,7 @@
'Reject': 'Rejeter',
'Reject %s is not defined': "Rejeté %s n'est pas défini",
'Reject article is not published': "Rejeté l'article n'est pas publié",
'Reject collaboration is not defined': "Rejeté la collaboration n'est pas définie",
'Reject collaboration is not well formed': 'Rejeté la collaboration est mal formatté',
'Reject collaborations is not defined': "Rejeté la collaboration n'est pas définie",
'Reject conference dates is not well formed': 'Rejecté les dates de la conférence dates sont mal formatté',
......
# -*- coding: utf-8 -*-
"""test_all_harvester
"""
import pytest
from gluon import current
from harvest_tools.articles import (
MSG_NO_EDITOR,
MSG_TRANSFORM_PREPRINT)
from harvest_tools.base import (
MSG_FIX_ORIGIN,
MSG_IN_DB,
MSG_LOAD,
MSG_NO_ENTRY,
MSG_TOOMANY_SYNONYM)
from harvest_tools.checkandfix import (
MSG_NO_AUTHOR,
MSG_NO_CONF_DATE,
MSG_NO_DATE,
MSG_NO_MY_AUTHOR,
MSG_NO_REF,
MSG_NO_YEAR,
MSG_TEMPORARY_RECORD,
MSG_TO_MANY_DATE,
MSG_TO_MANY_FAUTHOR,
MSG_TO_MANY_YEAR,
MSG_WELL_FORMED_CONF_DATES,
MSG_WELL_FORMED_DATE,
MSG_WELL_FORMED_EDITOR)
from harvest_tools.factory import build_harvester_tool
from harvest_tools.preprints import (
MSG_PREPRINT_IS_PAPER,
MSG_PREPRINT_IS_CONFERENCE,
MSG_PREPRINT_IS_THESIS,
MSG_PREPRINT_NO_NUMBER)
from harvest_tools.reports import MSG_REPORT_NO_NUMBER
from harvest_tools.thesis import MSG_NO_THESIS
from invenio_tools.base import MSG_NO_CONF, MSG_NO_PUBLISHER
@pytest.fixture(scope="module")
def messages():
T = current.T
set_msgs = {
T(MSG_NO_EDITOR),
T(MSG_TRANSFORM_PREPRINT),
T(MSG_FIX_ORIGIN),
T(MSG_IN_DB),
T(MSG_LOAD),
T(MSG_NO_ENTRY % "collaborations"),
T(MSG_NO_ENTRY % "countries"),
T(MSG_NO_ENTRY % "publishers"),
T(MSG_TOOMANY_SYNONYM),
T(MSG_NO_AUTHOR),
T(MSG_NO_CONF),
T(MSG_NO_CONF_DATE),
T(MSG_NO_DATE),
T(MSG_NO_MY_AUTHOR),
T(MSG_NO_PUBLISHER),
T(MSG_NO_REF),
T(MSG_NO_THESIS),
T(MSG_NO_YEAR),
T(MSG_PREPRINT_IS_PAPER),
T(MSG_PREPRINT_IS_CONFERENCE),
T(MSG_PREPRINT_IS_THESIS),
T(MSG_PREPRINT_NO_NUMBER),
T(MSG_REPORT_NO_NUMBER),
T(MSG_TEMPORARY_RECORD),
T(MSG_TO_MANY_DATE),
T(MSG_TO_MANY_FAUTHOR),
T(MSG_TO_MANY_YEAR),
T(MSG_WELL_FORMED_CONF_DATES),
T(MSG_WELL_FORMED_DATE),
T(MSG_WELL_FORMED_EDITOR)}
return set_msgs
def test_astro_gamma(messages):
"""Test all harvesters for the astro-gamma team.
"""
# Parameters
# Select the current year in order to test different case
db = current.db
id_team = 2
year = current.request.now.year
# get the list of harvester
query = db.harvesters.id_teams == id_team
# process
for harvester in db(query).iterselect():
tool = build_harvester_tool(
db,
harvester.id_teams,
harvester.id_projects,
harvester.controller,
harvester.id_categories,
year_start=str(year),
year_end="",
dry_run=True,
debug=False)
tool.process_url(harvester.host, harvester.collections)
# 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(messages)
def test_atlas_all(messages):
"""Test all harvesters for the Atlas team.
"""
# Parameters
# Select the current year in order to test different case
db = current.db
id_team = 3
year = current.request.now.year
# get the list of harvester
query = db.harvesters.id_teams == id_team
# process
for harvester in db(query).iterselect():
tool = build_harvester_tool(
db,
harvester.id_teams,
harvester.id_projects,
harvester.controller,
harvester.id_categories,
year_start=str(year),
year_end="",
dry_run=True,
debug=False)
tool.process_url(harvester.host, harvester.collections)
# 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(messages)
def test_lhcb_all(messages):
"""Test all harvesters for the LHCb team.
"""
# Parameters
# Select the current year in order to test different case
db = current.db
id_team = 7
year = current.request.now.year
# get the list of harvester
query = db.harvesters.id_teams == id_team
# process
for harvester in db(query).iterselect():
tool = build_harvester_tool(
db,
harvester.id_teams,
harvester.id_projects,
harvester.controller,
harvester.id_categories,
year_start=str(year),
year_end="",
dry_run=True,
debug=False)
tool.process_url(harvester.host, harvester.collections)
# 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(messages)
# -*- coding: utf-8 -*-
"""test_harvest_article
"""test_single_harvester
"""
from gluon import current
......@@ -33,38 +33,54 @@ from harvest_tools.checkandfix import (
MSG_WELL_FORMED_EDITOR)
from harvest_tools.factory import build_harvester_tool
from harvest_tools.preprints import MSG_PREPRINT_NO_NUMBER
from harvest_tools.preprints import (
MSG_PREPRINT_IS_PAPER,
MSG_PREPRINT_IS_CONFERENCE,
MSG_PREPRINT_IS_THESIS,
MSG_PREPRINT_NO_NUMBER)
from harvest_tools.reports import MSG_REPORT_NO_NUMBER
from harvest_tools.thesis import MSG_NO_THESIS
from invenio_tools.base import MSG_NO_CONF, MSG_NO_PUBLISHER
@pytest.fixture(scope="module")
def messages():
T = current.T
set_msgs = {
T(MSG_NO_EDITOR),
T(MSG_TRANSFORM_PREPRINT),
T(MSG_FIX_ORIGIN),
T(MSG_IN_DB),
T(MSG_LOAD),
T(MSG_NO_ENTRY),
T(MSG_NO_ENTRY % "collaborations"),
T(MSG_NO_ENTRY % "countries"),
T(MSG_NO_ENTRY % "publishers"),
T(MSG_TOOMANY_SYNONYM),
T(MSG_NO_AUTHOR),
T(MSG_NO_CONF),
T(MSG_NO_CONF_DATE),
T(MSG_NO_DATE),
T(MSG_NO_MY_AUTHOR),
T(MSG_NO_PUBLISHER),
T(MSG_NO_REF),
T(MSG_NO_THESIS),
T(MSG_NO_YEAR),
T(MSG_PREPRINT_IS_PAPER),
T(MSG_PREPRINT_IS_CONFERENCE),
T(MSG_PREPRINT_IS_THESIS),
T(MSG_PREPRINT_NO_NUMBER),
T(MSG_REPORT_NO_NUMBER),
T(MSG_TEMPORARY_RECORD),
T(MSG_TO_MANY_DATE),
T(MSG_TO_MANY_FAUTHOR),
T(MSG_TO_MANY_YEAR),
T(MSG_WELL_FORMED_CONF_DATES),
T(MSG_WELL_FORMED_DATE),
T(MSG_WELL_FORMED_EDITOR),
T(MSG_PREPRINT_NO_NUMBER),
T(MSG_REPORT_NO_NUMBER),
T(MSG_NO_THESIS)}
T(MSG_WELL_FORMED_EDITOR)}
return set_msgs
......
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