Commit 896fd76d authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update RecordHepPubli and CheckAnFix to fix collaboration handling

parent fbddce74
......@@ -372,7 +372,8 @@ class CheckAndFix(object):
Raises:
CheckException:
* the collaboration is unknown (neither collaborationnor synonym)
* the collaboration is unknown (neither collaboration
or synonym)
* more than one synonym found.
"""
self.logger.debug(f"{T6}check collaboration")
......@@ -391,15 +392,22 @@ class CheckAndFix(object):
collaboration = db.collaborations[dbid].collaboration
if collaboration != val:
# one collaboration
if isinstance(record["corporate_name"], dict):
record["corporate_name"]["collaboration"] = collaboration
# several collaboration
# replace the list of dictionary by a single one
else:
record["corporate_name"] = \
{"collaboration": collaboration}
# cds.cern.ch
if "corporate_name" in record:
# one collaboration
if isinstance(record["corporate_name"], dict):
record["corporate_name"]["collaboration"] = \
collaboration
# several collaboration
# replace the list of dictionary by a single one
else:
record["corporate_name"] = \
{"collaboration": collaboration}
# inspirehep.net
elif "collaborations" in record:
record["collaborations"] = [{"value": collaboration}]
except ToolException as e:
raise CheckException(*e.args)
......
......@@ -209,14 +209,7 @@ class RecordHepPubli(RecordHep, PluginAuthors, PluginPublicationInfo):
if collaborations is None:
return ""
lst = []
for elt in collaborations:
val = elt["value"]
val = (val if val.endswith("ollaboration")
else f"{val} Collaboration")
lst.append(val)
lst = [elt["value"] for elt in collaborations]
return CLEAN_COLLABORATION(", ".join(lst))
def paper_url(self):
......
......@@ -155,7 +155,7 @@ def test_find_authors_by_affiliation_ins_05031(record):
# Other methods
#
def test_collaboration_ins_05040(record):
assert record.collaboration() == "LHCb Collaboration"
assert record.collaboration() == "LHCb"
def test_is_published_ins_05041(record):
......
......@@ -124,3 +124,10 @@ def test_get_my_authors_cds_13008(svc, reccds):
"K. De Bruyn|R. Le Gac|O. Leroy|" \
"G. Mancinelli|M. Martin|A. Mordà|" \
"J. Serrano|A. Tayduganov|A. Tsaregorodtsev"
def test_collaboration_ins_13009(svc):
# require the CPPM database (test_limbra)
record = load_record("inspirehep.net", 1826290, shelf="literature")
svc.collaboration(record)
assert record.collaboration() == "HESS Collaboration"
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