Commit 0a0b3f9d authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Polisg Record, RecordPubli and associated tests.

parent c620ca3c
......@@ -21,8 +21,6 @@ class Record(dict):
+-----------------------------+-----------------------------+
| field (cds) | field (inspirehep) |
+=============================+=============================+
| | FIXME_OAI |
+-----------------------------+-----------------------------+
| abstract | abstract |
+-----------------------------+-----------------------------+
| accelerator_experiment | accelerator_experiment |
......@@ -69,7 +67,7 @@ class Record(dict):
+-----------------------------+-----------------------------+
| number_of_reviews | number_of_reviews |
+-----------------------------+-----------------------------+
| oai | |
| oai | FIXME_OAI |
+-----------------------------+-----------------------------+
| other_report_number | |
+-----------------------------+-----------------------------+
......
......@@ -660,20 +660,10 @@ class RecordPubli(Record):
the string is empty when no URLs are found.
"""
# depends on the store
# start with CDS looking for the field `url`
if "url" in self:
data = self["url"]
li = (data if isinstance(data, list) else [data])
li = [di["url"] for di in li if di["description"] == "Preprint"]
if len(li) == 1:
return li[0]
# scan the list of files
# work for both stores.
pdf = "%s.pdf" % self.preprint_number()
pdf = f"{self.preprint_number()}.pdf"
pdf = pdf.replace(ARXIV + ":", "")
li = self._get("files", "url", force_list=True)
li = [el for el in li if el.endswith(pdf)]
......
......@@ -204,7 +204,8 @@ def test_preprint_number_ins_04020(recins):
def test_paper_url_cds_04021(reccds):
assert reccds.paper_url() == "http://arxiv.org/pdf/1410.0149.pdf"
assert reccds.paper_url() == \
"http://cds.cern.ch/record/1951625/files/arXiv:1410.0149.pdf"
def test_paper_url_ins_04022(recins):
......@@ -231,3 +232,45 @@ def test_submitted_ins_04026(recins):
def test_title_cds_04027(reccds):
assert reccds.title() == "Precision luminosity measurements at LHCb"
def test_all_ins_042028():
"""same article oai:inspirehet.net:1762838 and oai:cds.cern.ch:2698323"""
rec = load_record("inspirehep.net", 1762838)
assert rec.title() == \
r"Updated measurement of decay-time-dependent CP asymmetries " \
r"in $D^0 \to K^+K^-$ and $D^0 \to \pi^+\pi^-$ decays"
assert rec.paper_reference() == "Phys.Rev. D101 2020 012005"
assert rec.first_author() == "Aaij, Roel"
assert rec.primary_oai() == "oai:inspirehep.net:1762838"
assert rec.secondary_oai() == "oai:cds.cern.ch:2698323"
assert rec.paper_url() == \
"http://inspirehep.net/record/1762838/files/1911.01114.pdf"
assert rec.preprint_number() == "arXiv:1911.01114"
assert rec.report_number() == "CERN-EP-2019-225, LHCb-PAPER-2019-032"
def test_all_ins_042029():
"""same article oai:inspirehet.net:1762838 and oai:cds.cern.ch:2698323"""
rec = load_record("cds.cern.ch", 2698323)
assert rec.title() == \
r"Updated measurement of decay-time-dependent CP asymmetries " \
r"in $D^0 \to K^+K^-$ and $D^0 \to \pi^+\pi^-$ decays"
assert rec.paper_reference() == "Phys. Rev. D 101 2020 012005"
assert rec.first_author() == "Aaij, Roel"
assert rec.primary_oai() == "oai:cds.cern.ch:2698323"
assert rec.secondary_oai() == "oai:inspirehep.net:1762838"
assert rec.paper_url() == \
"http://cds.cern.ch/record/2698323/files/1911.01114.pdf"
assert rec.preprint_number() == "arXiv:1911.01114"
assert rec.report_number() == "LHCB-PAPER-2019-032, LHCB-PAPER-2019-032-003"
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