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

Propagate new Record classes in tests and CheckAndFix.

parent d2a8a4fb
...@@ -6,7 +6,7 @@ import traceback ...@@ -6,7 +6,7 @@ import traceback
from base import family_name_fr, MSG_CRASH, MSG_LOAD from base import family_name_fr, MSG_CRASH, MSG_LOAD
from invenio_tools import CheckException from invenio_tools import CheckException, RecordConf, RecordThesis
from publicationstool import PublicationsTool from publicationstool import PublicationsTool
from plugin_dbui import UNDEF_ID from plugin_dbui import UNDEF_ID
...@@ -100,11 +100,11 @@ class Preprints(PublicationsTool): ...@@ -100,11 +100,11 @@ class Preprints(PublicationsTool):
self.logs[-1].reject(MSG_PREPRINT_IS_PAPER, record.year()) self.logs[-1].reject(MSG_PREPRINT_IS_PAPER, record.year())
return False return False
if record.is_conference_data(): if isinstance(record, RecordConf):
self.logs[-1].reject(MSG_PREPRINT_IS_CONFERENCE, record.year()) self.logs[-1].reject(MSG_PREPRINT_IS_CONFERENCE, record.year())
return False return False
if record.is_thesis(): if isinstance(record, RecordThesis):
self.logs[-1].reject(MSG_PREPRINT_IS_THESIS, record.year()) self.logs[-1].reject(MSG_PREPRINT_IS_THESIS, record.year())
return False return False
......
...@@ -7,7 +7,7 @@ import traceback ...@@ -7,7 +7,7 @@ import traceback
from base import family_name_fr, MSG_CRASH, MSG_LOAD from base import family_name_fr, MSG_CRASH, MSG_LOAD
from invenio_tools import CheckException from invenio_tools import CheckException, RecordThesis
from publicationstool import PublicationsTool from publicationstool import PublicationsTool
from plugin_dbui import get_id, UNDEF_ID from plugin_dbui import get_id, UNDEF_ID
...@@ -113,7 +113,7 @@ class Thesis(PublicationsTool): ...@@ -113,7 +113,7 @@ class Thesis(PublicationsTool):
if self.dbg: if self.dbg:
print "select thesis record" print "select thesis record"
if record.is_thesis(): if isinstance(record, RecordThesis):
return True return True
self.logs[-1].reject(MSG_NO_THESIS, record.year()) self.logs[-1].reject(MSG_NO_THESIS, record.year())
......
...@@ -5,13 +5,15 @@ ...@@ -5,13 +5,15 @@
import re import re
import regex import regex
from base import is_conference, OAI_URL, REG_OAI, REG_YEAR from base import OAI_URL, REG_OAI, REG_YEAR
from exception import CheckException from exception import CheckException
from filters import CLEAN_REVIEW from filters import CLEAN_REVIEW
from gluon import current from gluon import current
from inveniostore import InvenioStore from inveniostore import InvenioStore
from marc12 import Marc12 from marc12 import Marc12
from plugin_dbui import get_id from plugin_dbui import get_id
from recordconf import RecordConf
from recordthesis import RecordThesis
DECODE_ARXIV = re.compile("arXiv:(\d{2})(\d{2})\.") DECODE_ARXIV = re.compile("arXiv:(\d{2})(\d{2})\.")
...@@ -116,7 +118,7 @@ class CheckAndFix(object): ...@@ -116,7 +118,7 @@ class CheckAndFix(object):
""" """
val = u'' val = u''
if record.is_conference_data(): if isinstance(record, RecordConf):
# INSPIREHEP start date encoded as 2014-12-31 # INSPIREHEP start date encoded as 2014-12-31
if "x" in record["111"]: if "x" in record["111"]:
...@@ -127,7 +129,7 @@ class CheckAndFix(object): ...@@ -127,7 +129,7 @@ class CheckAndFix(object):
val = record["111"]["z"] val = record["111"]["z"]
val = "%s-%s-%s" % (val[0:4], val[4:6], val[6:8]) val = "%s-%s-%s" % (val[0:4], val[4:6], val[6:8])
elif record.is_thesis(): elif isinstance(record, RecordThesis):
val = record.these_defense() val = record.these_defense()
else: else:
...@@ -286,10 +288,7 @@ class CheckAndFix(object): ...@@ -286,10 +288,7 @@ class CheckAndFix(object):
raise CheckException(MSG_WELL_FORMED_COLLABORATION) raise CheckException(MSG_WELL_FORMED_COLLABORATION)
def conference(self, record): def conference(self, record):
"""Get the conference data associated to a talk/proceeding and """check country and conference date
push them in the record.
@note: the conference is looks by its key.
@type record: L{Record} @type record: L{Record}
@param record: @param record:
...@@ -298,7 +297,7 @@ class CheckAndFix(object): ...@@ -298,7 +297,7 @@ class CheckAndFix(object):
""" """
# conference information are available, i.e proceeding # conference information are available, i.e proceeding
if not is_conference(record): if not isinstance(record, RecordConf):
return return
# check country information (all valid countries have been enter once) # check country information (all valid countries have been enter once)
...@@ -421,7 +420,7 @@ class CheckAndFix(object): ...@@ -421,7 +420,7 @@ class CheckAndFix(object):
""" """
# protection # protection
if not record.is_thesis(): if not isinstance(record, RecordThesis):
return return
# CPPM: fix the name of Aix-Marseille university # CPPM: fix the name of Aix-Marseille university
......
...@@ -19,7 +19,7 @@ import pytest ...@@ -19,7 +19,7 @@ import pytest
from harvest_tools import format_author_fr from harvest_tools import format_author_fr
from invenio_tools import CheckAndFix, load_record from invenio_tools import CheckAndFix, load_record, RecordThesis
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
...@@ -55,7 +55,7 @@ def test_these_directors(record): ...@@ -55,7 +55,7 @@ def test_these_directors(record):
def test_is_thesis(record): def test_is_thesis(record):
assert record.is_thesis() assert isinstance(record, RecordThesis)
def test_submitted(record): def test_submitted(record):
......
...@@ -19,7 +19,7 @@ import pytest ...@@ -19,7 +19,7 @@ import pytest
from harvest_tools import format_author_fr from harvest_tools import format_author_fr
from invenio_tools import CheckAndFix, load_record from invenio_tools import CheckAndFix, load_record, RecordThesis
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
...@@ -55,7 +55,7 @@ def test_these_directors(record): ...@@ -55,7 +55,7 @@ def test_these_directors(record):
def test_is_thesis(record): def test_is_thesis(record):
assert record.is_thesis() assert isinstance(record, RecordThesis)
def test_submitted(record): def test_submitted(record):
......
...@@ -23,7 +23,7 @@ Note: ...@@ -23,7 +23,7 @@ Note:
import pytest import pytest
from invenio_tools import load_record from invenio_tools import load_record, RecordPubli
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
...@@ -71,9 +71,8 @@ def test_institutes(record): ...@@ -71,9 +71,8 @@ def test_institutes(record):
def test_is_article(record): def test_is_article(record):
assert record.is_conference_data() == False assert isinstance(record, RecordPubli)
assert record.is_published() == True assert record.is_published() == True
assert record.is_thesis() == False
def test_oai(record): def test_oai(record):
......
...@@ -22,7 +22,7 @@ Note: ...@@ -22,7 +22,7 @@ Note:
import pytest import pytest
from invenio_tools import load_record from invenio_tools import load_record, RecordPubli
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
...@@ -69,9 +69,8 @@ def test_institutes(record): ...@@ -69,9 +69,8 @@ def test_institutes(record):
def test_is_article(record): def test_is_article(record):
assert record.is_conference_data() == False assert isinstance(record, RecordPubli)
assert record.is_published() == True assert record.is_published() == True
assert record.is_thesis() == False
def test_oai(record): def test_oai(record):
......
...@@ -18,13 +18,12 @@ Note: ...@@ -18,13 +18,12 @@ Note:
""" """
import pytest import pytest
from invenio_tools import load_record from invenio_tools import load_record, RecordConf
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def record(): def record():
rec = load_record('cds.cern.ch', 1411352) return load_record('cds.cern.ch', 1411352)
return rec
def test_authors(record): def test_authors(record):
...@@ -88,9 +87,8 @@ def test_institutes(record): ...@@ -88,9 +87,8 @@ def test_institutes(record):
assert record.is_institute_defined() == False assert record.is_institute_defined() == False
def test_is_proceeding(record): def test_is_proceeding(record):
assert record.is_conference_data() == True assert isinstance(record, RecordConf)
assert record.is_published() == True assert record.is_published() == True
assert record.is_thesis() == False
def test_oai(record): def test_oai(record):
......
...@@ -20,13 +20,12 @@ Note: ...@@ -20,13 +20,12 @@ Note:
""" """
import pytest import pytest
from invenio_tools import load_record from invenio_tools import load_record, RecordConf
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def record(): def record():
rec = load_record('inspirehep.net', 1276938) return load_record('inspirehep.net', 1276938)
return rec
def test_authors(record): def test_authors(record):
...@@ -93,9 +92,8 @@ def test_institutes(record): ...@@ -93,9 +92,8 @@ def test_institutes(record):
def test_is_proceeding(record): def test_is_proceeding(record):
assert record.is_conference_data() == True assert isinstance(record, RecordConf)
assert record.is_published() == False assert record.is_published() == False
assert record.is_thesis() == False
def test_oai(record): def test_oai(record):
......
...@@ -16,13 +16,12 @@ Note: ...@@ -16,13 +16,12 @@ Note:
import pytest import pytest
from invenio_tools import load_record from invenio_tools import load_record, RecordConf
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def record(): def record():
rec = load_record('cds.cern.ch', 1550918) return load_record('cds.cern.ch', 1550918)
return rec
def test_authors(record): def test_authors(record):
...@@ -89,9 +88,8 @@ def test_institutes(record): ...@@ -89,9 +88,8 @@ def test_institutes(record):
def test_is_proceeding(record): def test_is_proceeding(record):
assert record.is_conference_data() == True assert isinstance(record, RecordConf)
assert record.is_published() == False assert record.is_published() == False
assert record.is_thesis() == False
def test_oai(record): def test_oai(record):
......
...@@ -20,7 +20,7 @@ Note: ...@@ -20,7 +20,7 @@ Note:
import pytest import pytest
from invenio_tools import load_record from invenio_tools import load_record, RecordThesis
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
...@@ -62,9 +62,8 @@ def test_institutes(record): ...@@ -62,9 +62,8 @@ def test_institutes(record):
def test_is_phd(record): def test_is_phd(record):
assert record.is_conference_data() == False assert isinstance(record, RecordThesis)
assert record.is_published() == False assert record.is_published() == False
assert record.is_thesis() == True
def test_oai(record): def test_oai(record):
......
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