Commit 14512643 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update RecordHep to standardize oai_url with Record

parent 4693ac92
......@@ -70,9 +70,9 @@ class RecordHep(dict):
Returns:
str:
the primary and secondary OAI identifier are separated
by a comma. The pattern of the identifier is ``oai:host:id`` or
an empty string when it is not defined.
* the pattern of the identifier is ``oai:host:id``
* primary and secondary OAI identifier are separated by a comma
* an empty string when it is not defined.
"""
lst = [self.primary_oai(), self.secondary_oai()]
......@@ -83,10 +83,9 @@ class RecordHep(dict):
Returns:
str:
the primary and secondary URLs are separated by a comma.
The pattern of the URL is ``https://host/api/literature/id``
or an empty string when it is not defined or when the OAI is
not well formed.
* the pattern of the URL is ``http://host/record/id``
* primary and secondary URLs are separated by a comma.
* an empty string when it is not defined
"""
lst = [self.primary_oai_url(), self.secondary_oai_url()]
......@@ -99,8 +98,8 @@ class RecordHep(dict):
Returns:
str:
the pattern of the string is ``oai:host:id``.
It is an empty string when not defined
* the pattern is ``oai:host:id``.
* empty string when it is not defined
"""
return f"oai:inspirehep.net:{self['control_number']}"
......@@ -110,13 +109,12 @@ class RecordHep(dict):
Returns:
str:
the pattern of the string is ``https://host/api/literature/id``.
The string is empty when it is not defined or when the OAI
is not well formed.
* the pattern is ``http://inspirehep.net/record/id``
* empty string when it is not defined
"""
recid = self["control_number"]
return f"https://inspirehep.net/api/literature/{recid}"
return f"http://inspirehep.net/record/{recid}"
def secondary_oai(self):
"""The secondary OAI identifier.
......@@ -126,8 +124,8 @@ class RecordHep(dict):
Returns:
str:
the pattern of the string is ``oai:host:id``.
It is an empty string when not defined
* the pattern is ``oai:host:id``.
* empty string when it is not defined
"""
if "external_system_identifiers" not in self:
......@@ -147,9 +145,8 @@ class RecordHep(dict):
Returns:
str:
the pattern of the string is ``https://host/record/id``.
The string is empty when it is not defined or when the OAI
is not well formed.
* the pattern is ``http://cds.cern.ch/record/id``
* empty string when it is not defined
"""
if "external_system_identifiers" not in self:
......@@ -157,6 +154,6 @@ class RecordHep(dict):
for elt in self["external_system_identifiers"]:
if elt["schema"] == "CDS":
return f"https://cds.cern.ch/record/{elt['value']}"
return f"http://cds.cern.ch/record/{elt['value']}"
return ""
......@@ -114,14 +114,14 @@ def test_oai_ins_03027(recins):
def test_primary_oai_url_ins_03028(recins):
assert recins.primary_oai_url() == \
"https://inspirehep.net/api/literature/1319638"
"http://inspirehep.net/record/1319638"
def test_secondary_oai_url_ins_03029(recins):
assert recins.secondary_oai_url() == "https://cds.cern.ch/record/1951625"
assert recins.secondary_oai_url() == "http://cds.cern.ch/record/1951625"
def test_oai_url_ins_03030(recins):
assert recins.oai_url() == \
"https://inspirehep.net/api/literature/1319638, "\
"https://cds.cern.ch/record/1951625"
"http://inspirehep.net/record/1319638, "\
"http://cds.cern.ch/record/1951625"
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