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

Update tests/basis

parent 0300a974
......@@ -21,7 +21,6 @@ from invenio_tools.recordpubli import PAPER_REFERENCE_KEYS
from plugin_dbui import CLEAN_SPACES, get_id, UNDEF_ID
DECODE_ARXIV = re.compile(r"arXiv:(\d{2})(\d{2})\.")
# Decode submitted date: DD MMM YYYY or DD MM YYY
......@@ -79,6 +78,7 @@ class CheckAndFix(object):
"""A collection of tools to check and repair the content of record.
"""
def __init__(self):
self.db = current.db
......@@ -118,13 +118,11 @@ class CheckAndFix(object):
# CDS has the opening and closing dates encoded as 20141231
if "opening_date" in meeting and "closing_date" in meeting:
fmt = "%Y%m%d"
val = meeting["opening_date"].replace("-", "")
opening = datetime.strptime(val, "%Y%m%d")
val = meeting["opening_date"]
opening = datetime.strptime(val, fmt)
val = meeting["closing_date"]
closing = datetime.strptime(val, fmt)
val = meeting["closing_date"].replace("-", "")
closing = datetime.strptime(val, "%Y%m%d")
return (opening, closing)
......
......@@ -158,16 +158,17 @@ def add_conference_data(recjson):
de = datetime.strptime(end, "%Y-%m-%d")
if ds.month == de.month:
sdate = f"{ds.day:02} - {de.day:02} " + ds.strftime("%b %Y")
sdate = f"{ds.day}-{de.day} " + ds.strftime("%b %Y")
else:
sdate = f"{ds.strftime('%d %b')} - {de.strftime('%d %b %Y')}"
sdate = f"{ds.strftime('%-d %b')} - {de.strftime('%-d %b %Y')}"
recjson["meeting_name"] = [{
"closing_date": end,
"coference_code": confjson["cnum"],
"country": address["country_code"],
"date": sdate,
"location": f"{address['country']}, {address['cities'][0]}",
"location": f"{address['cities'][0]}, {address['country']}",
"meeting": confjson["titles"][0]["title"],
"opening_date": start,
"year": confjson["opening_date"][:4]}]
......
......@@ -11,7 +11,7 @@ from invenio_tools.inveniostore import InvenioStore
def test_constructor_exception_01001():
with pytest.raises(CdsException):
InvenioStore("cds.cern.ch", shelf="literature")
InvenioStore("inspirehep", shelf="foo")
def test_get_ids_cds_01002():
......
......@@ -26,7 +26,7 @@ def reccds():
@pytest.fixture(scope="module")
def recins():
store = InvenioStore("inspirehep.net")
store = InvenioStore("inspirehep.net", shelf="literature")
recjson = store.get_record(1319638)
return Record(recjson)
......
......@@ -35,7 +35,7 @@ def reccds():
@pytest.fixture(scope="module")
def recins():
return load_record("inspirehep.net", 1319638)
return load_record("inspirehep.net", 1319638, shelf="literature")
def test_constructor_cds_04001(reccds):
......@@ -210,7 +210,7 @@ def test_paper_url_cds_04021(reccds):
def test_paper_url_ins_04022(recins):
assert recins.paper_url() == \
"http://inspirehep.net/record/1319638/files/arXiv:1410.0149.pdf"
"http://old.inspirehep.net/record/1319638/files/arXiv:1410.0149.pdf"
def test_report_number_cds_04023(reccds):
......@@ -249,7 +249,7 @@ def test_all_ins_042028():
assert rec.secondary_oai() == "oai:cds.cern.ch:2698323"
assert rec.paper_url() == \
"http://inspirehep.net/record/1762838/files/1911.01114.pdf"
"http://old.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"
......
......@@ -31,7 +31,7 @@ def reccds():
@pytest.fixture(scope="module")
def recins():
return load_record("inspirehep.net", 1089237)
return load_record("inspirehep.net", 1089237, shelf="literature")
def test_conference_location_cds_05001(reccds):
......
......@@ -11,7 +11,7 @@ from invenio_tools import load_record, RecordException, RecordInst
@pytest.fixture(scope="module")
def record():
return load_record("inspirehep.net", 902989)
return load_record("inspirehep.net", 902989, shelf="institutions")
def test_exception_host_ins_07001():
......@@ -21,7 +21,7 @@ def test_exception_host_ins_07001():
def test_exception_record_ins_07002():
record = load_record("inspirehep.net", 1319638)
record = load_record("inspirehep.net", 1319638, shelf="institutions")
with pytest.raises(RecordException):
RecordInst(record)
......
......@@ -53,7 +53,7 @@ def test_temporary_record_cds_08004(svc, reccds):
# get a list of recids
payload = {"p": "500__a:'*Temporary record*'", "of": "id", "rg": 10}
r = requests.get("https://inspirehep.net/search", params=payload)
r = requests.get("https://old.inspirehep.net/search", params=payload)
li = r.json()
# try with the oldest one to avoid issue with missing information, etc.
......
......@@ -25,7 +25,7 @@ def reccds():
@pytest.fixture(scope="module")
def recins():
return load_record("inspirehep.net", 1509922)
return load_record("inspirehep.net", 1509922, shelf="literature")
@pytest.fixture(scope="module")
......
......@@ -31,7 +31,7 @@ def reccds():
@pytest.fixture(scope="module")
def recins():
return load_record("inspirehep.net", 1089237)
return load_record("inspirehep.net", 1089237, shelf="literature")
@pytest.fixture(scope="module")
......
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