Commit 86023dfe authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the tests for the new Institute and modified Marc12 classes.

parent c5b1b298
......@@ -24,9 +24,16 @@ def is_institute(record):
# {'a': u'INSTITUTION'},
# {'a': u'CORE'}]}
if u"980" in record:
for di in record[u"980"]:
for k, v in di.iteritems():
if k == "a" and v == u"INSTITUTION":
return True
return False
\ No newline at end of file
if isinstance(record[u"980"], list):
for di in record[u"980"]:
for k, v in di.iteritems():
if k == "a" and v == u"INSTITUTION":
return True
elif isinstance(record[u"980"], dict) and \
"a" in record[u"980"] and \
record[u"980"]["a"] == u"INSTITUTION":
return True
return False
# -*- coding: utf-8 -*-
"""test the constructor and its exception
"""
import pytest
from invenio_tools import Institute, InstituteException, load_record
def test_exception_arg():
with pytest.raises(InstituteException):
Institute("")
def test_exception_host():
record = load_record("cds.cern.ch", 1951625)
with pytest.raises(InstituteException):
Institute(record)
def test_exception_record():
record = load_record("inspirehep.net", 1319638)
with pytest.raises(InstituteException):
Institute(record)
# -*- coding: utf-8 -*-
"""http://inspirehep.net/record/902989
"""
import pytest
from invenio_tools import Institute, load_record, Record
@pytest.fixture(scope="module")
def institute():
return load_record("inspirehep.net", 902989)
def test_future_id(institute):
assert institute.future_id() == u'CPPM, Marseille'
def test_id(institute):
assert institute.id() == u'Marseille, CPPM'
def test_name(institute):
assert institute.name() == u'Centre de Physique des Particules de Marseille (CPPM)'
def test_rex(institute):
assert institute.rex() == r'Marseille, CPPM|CPPM, Marseille'
# -*- coding: utf-8 -*-
"""http://cds.cern.ch/record/1951625
"""
import pytest
from invenio_tools import load_record, Record, Institute
@pytest.mark.parametrize("host, record_id, cls",
[("cds.cern.ch", 1951625, Record), # article
("inspirehep.net", 1319638, Record), # article
("inspirehep.net", 902989, Institute)]) # institution
def test_call(host, record_id, cls):
rep = load_record(host, record_id)
assert isinstance(rep, cls)
# -*- coding: utf-8 -*-
"""http://cds.cern.ch/record/1951625
"""
from invenio_tools import load_record, Record
def test_call():
rep = load_record('cds.cern.ch', 1951625)
assert isinstance(rep, 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