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