Commit 813338e7 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update check_my_affiliations to improve error reporting

parent 46ee3ddc
......@@ -564,6 +564,7 @@
'Regular expression defining the name of our institute.': 'Expression régulière definissant le nom de votre laboratoire.',
'Reject': 'Rejeter',
'Reject %s is not defined': "Rejeté %s n'est pas défini",
'Reject affiliations are not defined for all authors': "Rejeté les affiliations ne sont pas défini pour tous les auteurs",
'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é',
......
......@@ -10,6 +10,7 @@ from .base import (ARXIV,
is_conference,
is_institute,
is_thesis,
MSG_NO_AFFILIATION_FOR_ALL,
MSG_NO_CONF,
MSG_NO_COUNTRY,
MSG_NO_ENTRY,
......
......@@ -15,6 +15,10 @@ INS = ("inspirehep", "inspirehep.net")
MSG_INV_CONF = "Reject invalid conference information"
MSG_INV_CONF_KEY = "Reject invalid conference key"
MSG_NO_AFFILIATION_FOR_ALL = \
"Reject affiliations are not defined for all authors"
MSG_NO_CONF = "Reject no conference information"
MSG_NO_CONF_DATE = "Reject no conference date"
MSG_NO_CONF_ID_KEY = "Reject no conference identifier and key"
......
......@@ -6,6 +6,7 @@ import pprint
from .authorsmixin import AuthorsMixin, MSG_NO_MY_AUTHOR
from .base import (search_synonym,
MSG_NO_AFFILIATION_FOR_ALL,
MSG_UNKNOWN_COLLABORATION,
MSG_WELL_FORMED_DATE,
REG_DATE_YYYYMM,
......@@ -265,6 +266,10 @@ class RecordHepPubli(dict, AuthorsMixin, PublicationInfoMixin):
return
self.logger.debug(f"{T6}check my affiliation")
if not self.is_affiliation_for_all():
raise CheckException(MSG_NO_AFFILIATION_FOR_ALL)
value = self.find_affiliation(rex_institute)
if len(value) == 0:
......
......@@ -5,7 +5,8 @@
import pytest
from gluon import current
from store_tools import load_record, ToolException
from harvest_tools import get_rex_institute
from store_tools import CheckException, load_record, ToolException
def test_acl_cds1513204_50001():
......@@ -245,3 +246,17 @@ def test_acl_ins1386663_50011():
assert authors[0] == u"S. Adrián-Martínez"
assert authors[128] == u"J. D. Zornoza"
assert authors[139] == u"D. M. Coward"
def test_acl_ins1808873_50012():
"""
JSON 210125:
* No affiliations
"""
record = load_record("inspirehep.net", 1808873, shelf="literature")
rex_institute = get_rex_institute(current.db, current.app)
with pytest.raises(CheckException):
record.check_my_affiliation(rex_institute)
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