コード例 #1
0
def oaiResult(adds, deletes):
    oaipmhNode = createElement('oai:OAI-PMH')
    listRecords = createSubElement(oaipmhNode, 'oai:ListRecords')
    for i in range(adds + deletes):
        record = createSubElement(listRecords, 'oai:record')
        attrib = {'status': 'deleted'} if i >= adds else {}
        createSubElement(record, 'oai:header', attrib=attrib)
    return oaipmhNode
コード例 #2
0
ファイル: pleintest.py プロジェクト: seecr/meresco-rdf
 def testAddTwoRecordsWithSameUriAndDeleteLast(self):
     uri = "uri:someuri"
     rdfNode, description = createRdfNode(uri)
     createSubElement(description, "dc:title", text='One')
     consume(self.dna.all.add(identifier="identifier1", partname="ignored", lxmlNode=rdfNode.getroot()))
     rdfNode, description = createRdfNode(uri)
     createSubElement(description, "dc:title", text='Two')
     consume(self.dna.all.add(identifier="identifier2", partname="ignored", lxmlNode=rdfNode.getroot()))
     consume(self.dna.all.delete(identifier="identifier2"))
     record = self.oaiJazz.getRecord(identifier=uri)
     self.assertEquals(['One'], xpath(XML(self.storage.getData(identifier=record.identifier, name='rdf')), '/rdf:RDF/rdf:Description/dc:title/text()'))
コード例 #3
0
ファイル: oaiaddrecordtest.py プロジェクト: seecr/meresco-oai
    def testAddSetInfo(self):
        record = createElement("oai:record")
        header = createSubElement(record, "oai:header")
        createSubElement(header, "oai:setSpec", text="1")

        consume(self.subject.add("123", "oai_dc", record))

        self.assertEquals(["addOaiRecord"], self.observer.calledMethodNames())
        self.assertEquals("123", self.observer.calledMethods[0].kwargs["identifier"])
        self.assertEquals(set([("1", "1")]), self.observer.calledMethods[0].kwargs["sets"])
        self.assertEquals(
            [("oai_dc", "", "http://www.openarchives.org/OAI/2.0/")],
            self.observer.calledMethods[0].kwargs["metadataFormats"],
        )
コード例 #4
0
ファイル: utilstest.py プロジェクト: seecr/meresco-xml
    def testCreateElement(self):
        dc = createElement('oai_dc:dc',
                           nsmap=namespaces.select('oai_dc', 'dc'))
        createSubElement(dc, 'dc:title', text='<title>')
        self.assertXmlEquals(
            '<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title>&lt;title&gt;</dc:title></oai_dc:dc>',
            dc)

        self.assertXmlEquals(
            '<dc:iets xmlns:dc="http://purl.org/dc/elements/1.1/" key="&lt;&quot;value&quot;>">te"xt</dc:iets>',
            createElement('dc:iets',
                          attrib={'key': '<"value">'},
                          text='te"xt',
                          nsmap=namespaces.select('dc')))
コード例 #5
0
ファイル: oaiaddrecordtest.py プロジェクト: seecr/meresco-oai
    def testAddSetInfo(self):
        record = createElement('oai:record')
        header = createSubElement(record, 'oai:header')
        createSubElement(header, 'oai:setSpec', text='1')

        consume(self.subject.add('123', 'oai_dc', record))

        self.assertEqual(['updateSet', 'updateMetadataFormat', 'addOaiRecord'],
                         self.observer.calledMethodNames())
        self.assertEqual('123',
                         self.observer.calledMethods[2].kwargs['identifier'])
        self.assertEqual({
            'setSpec': '1',
            'setName': '1'
        }, self.observer.calledMethods[0].kwargs)
        self.assertEqual(
            {
                'prefix': 'oai_dc',
                'schema': '',
                'namespace': "http://www.openarchives.org/OAI/2.0/"
            }, self.observer.calledMethods[1].kwargs)
コード例 #6
0
ファイル: utilstest.py プロジェクト: seecr/meresco-xml
    def testCreateElement(self):
        dc = createElement('oai_dc:dc', nsmap=namespaces.select('oai_dc', 'dc'))
        createSubElement(dc, 'dc:title', text='<title>')
        self.assertXmlEquals('<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title>&lt;title&gt;</dc:title></oai_dc:dc>', dc)

        self.assertXmlEquals('<dc:iets xmlns:dc="http://purl.org/dc/elements/1.1/" key="&lt;&quot;value&quot;>">te"xt</dc:iets>', createElement('dc:iets', attrib={'key':'<"value">'}, text='te"xt', nsmap=namespaces.select('dc')))