diff --git a/sru/tests/test_almasru.py b/sru/tests/test_almasru.py index 9fd155e20915c3749f421d59a1f40b469cf41868..8118deb1117c4888eff445e16dc83c16559c0b74 100644 --- a/sru/tests/test_almasru.py +++ b/sru/tests/test_almasru.py @@ -1,26 +1,40 @@ +"""Tests for almasru""" + +from xml.etree.ElementTree import Element import pytest import sru.almasru as almasru RETRIEVER = almasru.RecordRetriever('obv-at-oenb', '43ACC_ONB', 'marcxml') +QUERY_MULTIPLE = "alma.local_control_field_009=AC13320616 OR alma.local_control_field_009=AC13320328" +QUERY_UNIQUE = "alma.local_control_field_009=AC13320616" +QUERY_HUNDREDS = "alma.creator=Stocker" class TestRecordRetriever: + """Test RecordRetriever""" def test_erroneous_xml(self): with pytest.raises(almasru.SruException): RETRIEVER.by_mms_id('MMS-ID') def test_get_multiple(self): - query = "alma.local_control_field_009=AC13320616 OR alma.local_control_field_009=AC13320328" - RETRIEVER.get_multiple(query) + RETRIEVER.get_multiple(QUERY_MULTIPLE) assert True def test_get_unique(self): - query = "alma.local_control_field_009=AC13320616" - RETRIEVER.get_unique(query) + RETRIEVER.get_unique(QUERY_UNIQUE) assert True def test_not_unique(self): - query = "alma.local_control_field_009=AC13320616 OR alma.local_control_field_009=AC13320328" with pytest.raises(almasru.NotUnique): - RETRIEVER.get_unique(query) + RETRIEVER.get_unique(QUERY_MULTIPLE) + + def test_get_multiple_has_elements(self): + first_element = RETRIEVER.get_multiple(QUERY_MULTIPLE)[0] + assert isinstance(first_element, Element) + +# The following takes approx 2 minutes. Only uncomment if you have the time! + def test_get_multiple_hundreds(self): + hundreds = RETRIEVER.get_multiple(QUERY_HUNDREDS) + num_of_elements = len(hundreds) + assert int(num_of_elements) is 771