e567862326cfd2b8ecfe08792cb738c3c8cbd697
[wolnelektury.git] / apps / oai / tests / oaipmhapi.py
1
2
3 from catalogue.test_utils import WLTestCase
4 from catalogue import models
5 from nose.tools import raises
6 from oai.handlers import *
7 from oaipmh.server import *
8 from os import path
9 from oaipmh.metadata import MetadataRegistry
10 from lxml import etree
11
12
13 class BookMetadataTest(WLTestCase):
14     def setUp(self):
15         super(BookMetadataTest, self).setUp()
16         xml = path.join(path.dirname(__file__), 'files/lubie-kiedy-kobieta.xml')
17         self.book = models.Book.from_xml_file(xml)
18
19         xml = path.join(path.dirname(__file__), 'files/antygona.xml')
20         self.book2 = models.Book.from_xml_file(xml)
21
22         self.catalogue = Catalogue()
23         mr = MetadataRegistry()
24         mr.registerWriter('oai_dc', oai_dc_writer)
25         nsmap = {'oai_dc': NS_OAIDC, 'dc': NS_DC, 'xsi': NS_XSI}
26         self.xml = XMLTreeServer(self.catalogue, mr, nsmap)
27
28     def test_get_record(self):
29         sch = self.xml.getRecord(identifier='lubie-kiedy-kobieta',
30                                  metadataPrefix='oai_dc')
31         etree.dump(sch.getroot())
32         sch = self.xml.listRecords(metadataPrefix='oai_dc')
33         etree.dump(sch.getroot())
34
35     def test_selecting(self):
36         records, token = self.catalogue.listRecords(**{'set': 'epoch:starozytnosc'})
37         print records