Skip to content
Snippets Groups Projects
Commit fe9d4ff7 authored by gabriele-h's avatar gabriele-h
Browse files

First simple tests for almasru

parent 072420db
No related branches found
No related tags found
No related merge requests found
"""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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment