Commit 2297f17a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Revisit tests/issues:test_50_acl

parent 027b368d
# -*- coding: utf-8 -*-
"""test_acl
"""test_acl_50
* collection of article with issues
"""
import pytest
from harvest_tools.checkandfix import CheckAndFix, ToolException
from store_tools import load_record
@pytest.fixture(scope="module")
def svc():
return CheckAndFix()
from gluon import current
from store_tools import load_record, ToolException
def test_acl_cds1513204(svc):
def test_acl_cds1513204_50001():
"""
XML:
* The OAI for cds.cern.ch is a list:
......@@ -25,15 +18,13 @@ def test_acl_cds1513204(svc):
* Protection in Record.primary_oai
"""
reccds = load_record("cds.cern.ch", 1513204)
record = load_record("cds.cern.ch", 1513204)
assert reccds.oai() == \
"oai:cds.cern.ch:1513204, oai:inspirehep.net:1216886"
assert record.oai() == "oai:cds.cern.ch:1513204, oai:inspirehep.net:1216886"
assert record.host() == "cds.cern.ch"
assert reccds.host() == "cds.cern.ch"
def test_acl_cds1753190(svc):
def test_acl_cds1753190_50002():
"""
XML:
* Paper is published but there are error in the paper reference
......@@ -47,25 +38,27 @@ def test_acl_cds1753190(svc):
issue is detected by CheckAndFix. It raises an exception
informing the user of that the volume is wrong.
"""
reccds = load_record("cds.cern.ch", 1753190)
210118:
* journal is fine
* page number is fine
* Volume is wrong C75 instead of 75
assert reccds.paper_editor() == "Eur. Phys. J. C"
assert reccds.paper_pages() == "75"
"""
record = load_record("cds.cern.ch", 1753190)
# protect
assert not reccds.is_published()
assert record.paper_editor() == "Eur. Phys. J. C"
assert record.paper_pages() == "158"
assert record.paper_volume() == "C75"
assert record.is_published()
# crash
with pytest.raises(AttributeError):
assert reccds.paper_volume() == ""
record.format_editor()
# error detected and used properly informed
with pytest.raises(ToolException):
svc.paper_reference(reccds)
assert record.paper_editor() == "Eur. Phys. J. C"
assert record.paper_pages() == "158"
assert record.paper_volume() == "75"
def test_acl_cds1951625(svc):
def test_acl_cds1951625_50003():
"""
XML:
* The first author is not in the author list
......@@ -78,19 +71,19 @@ def test_acl_cds1951625(svc):
* Last one is fixed by CheckAndFix
"""
reccds = load_record("cds.cern.ch", 1951625)
record = load_record("cds.cern.ch", 1951625)
assert reccds.first_author() == "Aaij, Roel"
assert reccds.collaboration() == "LHCb Collaboration"
assert reccds.paper_year() == "2014"
assert reccds.submitted() == "01 Oct 2014"
assert record.first_author() == "Aaij, Roel"
assert record.collaboration() == "LHCb Collaboration"
assert record.paper_year() == "2014"
assert record.submitted() == "01 Oct 2014"
svc.submitted(reccds)
record.check_submitted_date()
assert reccds.submitted() == "2014-10-01"
assert record.submitted() == "2014-10-01"
def test_acl_cds2012165(svc):
def test_acl_cds2012165_50004():
"""
XML:
* The affiliation is not defined for one author
......@@ -99,14 +92,16 @@ def test_acl_cds2012165(svc):
* Same pattern
* Detect by RecordPubli.is_affiliation_for_all
210118: affiliation is defined for all authors
"""
reccds = load_record("cds.cern.ch", 2012165)
record = load_record("cds.cern.ch", 2012165)
assert reccds.is_affiliations()
assert not reccds.is_affiliation_for_all()
assert record.is_affiliations()
assert record.is_affiliation_for_all()
pattern = "Marseille, CPPM|CPPM, Marseille"
authors = reccds.find_authors_by_affiliation(pattern, sep=u"|")
authors = record.find_authors_by_affiliation(pattern, sep=u"|")
assert authors == u"Akar, Simon|Aslanides, Elie|Cogan, Julien|" \
u"Kanso, Walaa|Le Gac, Renaud|Leroy, Olivier|" \
......@@ -114,7 +109,7 @@ def test_acl_cds2012165(svc):
u"Serrano, Justine|Tsaregorodtsev, Andrei"
def test_acl_cds2014733(svc):
def test_acl_cds2014733_50005():
"""
JSON:
* paper URL not defined in record["url"]["url"]
......@@ -127,7 +122,7 @@ def test_acl_cds2014733(svc):
"http://cds.cern.ch/record/2014733/files/arXiv:1505.01654.pdf"
def test_acl_cds2234042(svc):
def test_acl_cds2234042_50006():
"""
JSON:
* Usually, the field ``prepublication`` is dictionary
......@@ -135,28 +130,25 @@ def test_acl_cds2234042(svc):
* Protection added Record.submitted and CheckAndFix.submitted
"""
reccds = load_record("cds.cern.ch", 2234042)
assert reccds.submitted() == "18 Nov 2016"
svc = CheckAndFix()
assert svc.submitted(reccds) is None
record = load_record("cds.cern.ch", 2234042)
assert reccds.submitted() == "2016-11-18"
assert record.submitted() == "18 Nov 2016"
assert record.check_submitted_date() is None
assert record.submitted() == "2016-11-18"
def test_acl_ins1221481(svc):
def test_acl_ins1221481_50007():
"""
JSON:
* Report number refers to the arXiv file
* Protected by the method RecordPubli.report_number
"""
recins = load_record('inspirehep.net', 1221481)
assert recins.report_number() == ""
record = load_record('inspirehep.net', 1221481, shelf="literature")
assert record.report_number() == ""
def test_acl_ins1278588(svc):
def test_acl_ins1278588_50008():
"""
XML:
* The first author is duplicate
......@@ -167,21 +159,21 @@ def test_acl_ins1278588(svc):
* Formatting, F. Last, is also working in that case
"""
recins = load_record("inspirehep.net", 1278588)
record = load_record("inspirehep.net", 1278588, shelf="literature")
assert recins.first_author() == "Lees, J.P."
assert recins.authors_as_list()[0:3] == [u"Lees, J.P.",
assert record.first_author() == "Lees, J.P."
assert record.authors_as_list()[0:3] == [u"Lees, J.P.",
u"Poireau, V.",
u"Tisserand, V."]
svc.format_authors(recins, fmt="F. Last")
record.check_format_authors(fmt="F. Last")
assert recins.authors_as_list()[0:3] == [u"J. P. Lees",
assert record.authors_as_list()[0:3] == [u"J. P. Lees",
u"V. Poireau",
u"V. Tisserand"]
def test_acl_ins1286523(svc):
def test_acl_ins1286523_50009():
"""
XML:
* The paper_year and submitted are OK but the year is wrong
......@@ -190,14 +182,14 @@ def test_acl_ins1286523(svc):
* No ore an issue since the year method is not used anymore
(the year can be derived using submitted()[0:4])
"""
recins = load_record("inspirehep.net", 1286523)
record = load_record("inspirehep.net", 1286523, shelf="literature")
assert recins.is_published()
assert recins.submitted() == "2014-03-19"
assert recins.paper_year() == "2015"
assert record.is_published()
assert record.submitted() == "2014-03-19"
assert record.paper_year() == "2015"
def test_acl_ins1319638(svc):
def test_acl_ins1319638_50010():
"""
XML:
* The first author is not in the author list
......@@ -210,24 +202,24 @@ def test_acl_ins1319638(svc):
* JINST is OK
"""
recins = load_record("inspirehep.net", 1319638)
record = load_record("inspirehep.net", 1319638, shelf="literature")
assert recins.authors_as_list()[0:3] == ["Aaij, Roel",
assert record.authors_as_list()[0:3] == ["Aaij, Roel",
"Adeva, Bernardo",
"Adinolfi, Marco"]
assert recins.collaboration() == "LHCb"
assert recins.is_published()
assert recins.paper_editor() == "JINST"
assert record.collaboration() == "LHCb"
assert record.is_published()
assert record.paper_editor() == "JINST"
svc.collaboration(recins)
svc.format_editor(recins)
record.check_collaboration(current.db)
record.format_editor()
assert recins.collaboration() == "LHCb Collaboration"
assert recins.paper_editor() == "JINST"
assert record.collaboration() == "LHCb Collaboration"
assert record.paper_editor() == "JINST"
def test_acl_ins1386663(svc):
def test_acl_ins1386663_50011():
"""
XML:
* Encoding of the first name
......@@ -236,18 +228,18 @@ def test_acl_ins1386663(svc):
* Fix by CheckAndFix
"""
recins = load_record("inspirehep.net", 1386663)
record = load_record("inspirehep.net", 1386663, shelf="literature")
authors = recins.authors_as_list()
authors = record.authors_as_list()
assert len(authors) == 140
assert authors[0] == u"Adrián-Martínez, S."
assert authors[128] == u"Zornoza, J.D."
assert authors[139] == u"Coward, D.M."
svc.format_authors(recins, fmt="F. Last")
record.check_format_authors(fmt="F. Last")
authors = recins.authors_as_list()
authors = record.authors_as_list()
assert len(authors) == 140
assert authors[0] == u"S. Adrián-Martínez"
......
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