Code layout change.
[wolnelektury.git] / src / oai / tests / oaipmhapi.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from catalogue.test_utils import WLTestCase
6 from catalogue import models
7 from oai.handlers import *
8 from oaipmh.server import *
9 from os import path
10 from oaipmh.metadata import MetadataRegistry
11 from lxml import etree
12
13
14 class BookMetadataTest(WLTestCase):
15     def setUp(self):
16         super(BookMetadataTest, self).setUp()
17         xml = path.join(path.dirname(__file__), 'files/lubie-kiedy-kobieta.xml')
18         self.book = models.Book.from_xml_file(xml)
19
20         xml = path.join(path.dirname(__file__), 'files/antygona.xml')
21         self.book2 = models.Book.from_xml_file(xml)
22
23         mr = MetadataRegistry()
24         self.catalogue = Catalogue(mr)
25
26         mr.registerWriter('oai_dc', oai_dc_writer)
27         nsmap = {'oai_dc': NS_OAIDC, 'dc': NS_DC, 'xsi': NS_XSI}
28         self.xml = XMLTreeServer(self.catalogue, mr, nsmap)
29
30     def test_get_record(self):
31         self.xml.getRecord(identifier='lubie-kiedy-kobieta',
32                                  metadataPrefix='oai_dc')
33         self.xml.listRecords(metadataPrefix='oai_dc')
34
35     def test_selecting(self):
36         records, token = self.catalogue.listRecords(**{'set': 'epoch:starozytnosc'})