Commit 2902fd6e authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Fix bugs and adapt tests to the synonym logic.

parent f03f2faf
......@@ -56,14 +56,14 @@ class Articles(Automaton):
self.logs[-1].reject(MSG_NO_EDITOR, record.year())
return False
self.check.format_editor(record)
self.check.publisher(record)
self.check.paper_reference(record)
self.check.submitted(record)
self.check.year(record)
self.check.format_editor(record)
self.check.format_authors(record, format_author_fr)
self.check.get_my_authors(record, family_name_fr)
except CheckException as e:
......
......@@ -241,21 +241,24 @@ class Automaton(object):
if not value:
return UNDEF_ID
id_rec = get_id(tablename, fieldname=value)
db = self.db
table = db[tablename]
kwargs = {}
kwargs[fieldname] = value
id_rec = get_id(table, **kwargs)
if id_rec is not None:
return id_rec
# nothing found, have a look to the synonyms
db = self.db
table = db[tablename]
query = table.synonyms.contains(value)
setrows = db(query)
# no synonym found, create the entry
ncount = setrows.count()
if ncount == 0 and create:
return table.insert(fieldname=value)
return table.insert(**kwargs)
# one synonym found
elif ncount == 1:
......
......@@ -41,9 +41,9 @@ class Proceedings(Automaton):
self.check.submitted(record)
self.check.year(record)
self.check.format_editor(record)
self.check.publisher(record)
self.check.paper_reference(record)
self.check.format_editor(record)
self.check.format_authors(record, format_author_fr)
self.check.get_my_authors(record, family_name_fr)
......
......@@ -389,7 +389,7 @@ class CheckAndFix(object):
if REG_COLLABORATION.match(val):
return
if self._is_synonym("collaboration", val):
if self._is_synonym("collaborations", val):
return
raise CheckException(MSG_WELL_FORMED_COLLABORATION)
......@@ -804,7 +804,7 @@ class CheckAndFix(object):
return
# erratum -- check the first entry
if isinstance(list):
if isinstance(val, list):
val = val[0]
id_publisher = get_id(db.publishers, abbreviation=val)
......
......@@ -24,5 +24,5 @@ def test_country_exception():
record = load_record('cds.cern.ch', 1559714)
svc = CheckAndFix()
with pytest.raises(CheckException):
svc.country(record)
# no exception since the value is define in the synonyms.
assert svc.country(record) is None
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