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

Improve tests lisibility.

parent e92f798b
......@@ -18,6 +18,7 @@ Note:
* The submitted date is not formatted: 01 Oct 2014
"""
import copy
import pytest
from gluon import current
......@@ -36,13 +37,17 @@ CPPM_AUTHORS = [u"S. Akar",
u"J. Serrano",
u"A. Tsaregorodtsev"]
@pytest.fixture(scope="module")
def record():
rec = load_record('cds.cern.ch', 1951625)
return load_record('cds.cern.ch', 1951625)
# apply all corrections for an article
svc = CheckAndFix()
@pytest.fixture(scope="module")
def recordfix(record):
rec = copy.deepcopy(record)
svc = CheckAndFix()
svc.authors(rec)
svc.format_authors(rec, format_author_fr)
svc.format_editor(rec)
......@@ -53,9 +58,13 @@ def record():
return rec
def test_authors(record):
def test_authors(record, recordfix):
authors = record.authors_as_list()
assert len(authors) == 703
assert authors[0] == "Adeva, Bernardo"
assert authors[-1] == "Zvyagin, Alexander"
authors = recordfix.authors_as_list()
assert len(authors) == 704
assert authors[0] == "R. Aaij"
assert authors[55] == "M.-O. Bettler"
......@@ -63,26 +72,29 @@ def test_authors(record):
assert authors[-1] == "A. Zvyagin"
def test_find_authors_by_institute(record):
def test_find_authors_by_institute(recordfix):
rex = current.app.reg_institute
assert rex == "Marseille, CPPM|CPPM, Marseille"
authors = record.find_authors_by_institute(rex, family_name_fr)
authors = recordfix.find_authors_by_institute(rex, family_name_fr)
authors = authors.split(", ")
assert authors == CPPM_AUTHORS
def test_first_author(record):
assert record.first_author() == "R. Aaij"
def test_first_author(record, recordfix):
assert record.first_author() == "Aaij, Roel"
assert recordfix.first_author() == "R. Aaij"
def test_my_authors(record):
assert record.my_authors.split(', ') == CPPM_AUTHORS
def test_my_authors(recordfix):
assert recordfix.my_authors.split(', ') == CPPM_AUTHORS
def test_paper_editor(record):
assert record.paper_editor() == "J Instrum"
def test_paper_editor(record, recordfix):
assert record.paper_editor() == "J. Instrum."
assert recordfix.paper_editor() == "J Instrum"
def test_submitted(record):
assert record.submitted() == ["2014-10-01"]
def test_submitted(record, recordfix):
assert record.submitted() == ["01 Oct 2014"]
assert recordfix.submitted() == ["2014-10-01"]
......@@ -32,7 +32,6 @@ def record():
@pytest.fixture(scope="module")
def recordfix(record):
rec = copy.deepcopy(record)
svc = CheckAndFix()
......
......@@ -13,138 +13,53 @@ Allow to test the brute force decoding with its mistakes.
Note:
* Only first author defined
"""
import copy
import pytest
from harvest_tools import format_author_fr
from invenio_tools import CheckAndFix, load_record
@pytest.fixture(scope="module")
def record():
rec = load_record('cds.cern.ch', 1550918)
return load_record('cds.cern.ch', 1550918)
@pytest.fixture(scope="module")
def recordfix(record):
rec = copy.deepcopy(record)
svc = CheckAndFix()
svc.authors(rec)
svc.conference(rec)
svc.format_authors(rec, format_author_fr)
svc.format_editor(rec)
svc.submitted(rec)
svc.year(rec)
return rec
def test_authors(record):
def test_authors(record, recordfix):
assert record.authors() == ""
assert recordfix.authors() == "R. Le Gac"
def test_collaboration(record):
assert record.collaboration() == ""
def test_conference_dates(record, recordfix):
assert record.conference_dates() == "19 - 24 May 2013"
assert recordfix.conference_dates() == "19-24 May 2013"
def test_conference_dates(record):
assert record.conference_dates() == "19-24 May 2013"
def test_conference_country(record):
def test_conference_country(record, recordfix):
assert record.conference_country() == "Brazil"
assert recordfix.conference_country() == "Brazil"
def test_conference_key(record):
assert record.conference_key() == "buzios20130519"
def test_conference_location(record):
assert record.conference_location() == "Buzios, Rio, Brazil"
def test_conference_title(record):
assert record.conference_title() == "Flavor Physics & CP Violation"
def test_conference_town(record):
assert record.conference_town() == "Buzios"
def test_conference_url(record):
assert record.conference_url() == ""
def test_conference_year(record):
def test_conference_year(record, recordfix):
assert record.conference_year() == "2013"
assert recordfix.conference_year() == "2013"
def test_first_author(record):
def test_first_author(record, recordfix):
assert record.first_author() == "Le Gac, R"
def test_first_institutes(record):
assert record.first_author_institutes() == u"CPPM, Aix-Marseille Université, CNRS/IN2P3, Marseille, France"
def test_host(record):
assert record.host() == "cds.cern.ch"
def test_id(record):
assert record.id() == "1550918"
def test_institutes(record):
institutes = record.institutes()
assert record.institutes() == []
assert record.is_institute_defined() == False
def test_is_proceeding(record):
assert record.is_conference_data() == True
assert record.is_published() == False
assert record.is_thesis() == False
def test_oai(record):
assert record.oai() == "oai:cds.cern.ch:1550918"
assert record.oai_url() == "http://cds.cern.ch/record/1550918"
def test_paper_reference(record):
assert record.paper_editor() == ""
assert record.paper_pages() == ""
assert record.paper_volume() == ""
assert record.paper_year() == ""
def test_paper_url(record):
assert record.paper_url() == ""
def test_preprint_number(record):
assert record.preprint_number() == ""
def test_submitted(record):
assert record.submitted() == ["2013-05-24"]
def test_reference_conference_id(record):
assert record.reference_conference_id() == "1545572"
def test_reference_conference_key(record):
assert record.reference_conference_key() == "buzios20130519"
def test_reference_conference_proceeding(record):
assert record.reference_conference_proceeding() == ""
def test_reference_conference_talk(record):
assert record.reference_conference_talk() == ""
def test_report_number(record):
assert record.report_number() == "LHCb-TALK-2013-160"
def test_title(record):
assert record.title() == "The LHCb Upgrade"
def test_year(record):
assert record.year() == "2013"
assert recordfix.first_author() == "R. Le Gac"
......@@ -16,6 +16,7 @@ Note:
* The year is not defined
"""
import copy
import pytest
......@@ -25,9 +26,13 @@ from invenio_tools import CheckAndFix, load_record
@pytest.fixture(scope="module")
def record():
rec = load_record('cds.cern.ch', 1632177)
svc = CheckAndFix()
return load_record('cds.cern.ch', 1632177)
@pytest.fixture(scope="module")
def recordfix(record):
rec = copy.deepcopy(record)
svc = CheckAndFix()
svc.authors(rec)
svc.format_authors(rec, format_author_fr)
svc.my_authors(rec)
......@@ -37,25 +42,31 @@ def record():
return rec
def test_authors(record):
assert record.authors() == "L. Chen"
def test_authors(record, recordfix):
assert record.authors() == ""
assert recordfix.authors() == "L. Chen"
def test_first_author(record):
assert record.first_author() == "L. Chen"
def test_first_author(record, recordfix):
assert record.first_author() == "Chen, Liming"
assert recordfix.first_author() == "L. Chen"
def test_these_defense(record):
def test_these_defense(record, recordfix):
assert record.these_defense() == "10 Dec 2013"
assert recordfix.these_defense() == "10 Dec 2013"
def test_these_directors(record):
assert record.these_directors() == "M. He, E. Monnier, C. Zhu"
def test_these_directors(record, recordfix):
assert record.these_directors() == "He, Mao, Monnier, Emmanuel, Zhu, Chengguang"
assert recordfix.these_directors() == "M. He, E. Monnier, C. Zhu"
def test_submitted(record):
assert record.submitted() == ['2013-12-10']
def test_submitted(record, recordfix):
assert record.submitted() == []
assert recordfix.submitted() == ['2013-12-10']
def test_year(record):
assert record.year() == "2013"
def test_year(record, recordfix):
assert record.year() == ""
assert recordfix.year() == "2013"
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