Exemple #1
0
class MetadataTestCase(unittest.TestCase):

    def setUp(self):
        self.file = RdfXmlMetadata()

    def tearDown(self):
        pass

    def parse(self, filename):
        fd = open(filename)
        try:
            self.file.parse(fd)
        finally:
            fd.close()

    def test_0000_queryEFNote(self):
        self.parse(join(input_dir, 'well-formed-3-node.xml'))
        answer = {
            u'key1': u'value1',
            u'key2': u'value2',
        }
        # must convert to dictionary for testign because of multiple 
        # results being unordered.
        results = dict(self.file.queryEFNote('ex'))
        self.assertEqual(answer, results)

    def test_0100_queryDC(self):
        self.parse(join(input_dir, 'well-formed-3-node.xml'))
        answer = [(
            ('dc:title', u'Test XML 3 node'),
            ('dc:creator', u'Tommy'), 
            ('dc:description', u'A test RDF/XML document'),
        )]
        # single result set, query ordered.
        results = self.file.queryDC('')
        self.assertEqual(answer, results)

    def test_0101_queryDC_partial(self):
        self.parse(join(input_dir, 'partial_dc.rdf'))
        answer = [(
            ('dc:title', u'Test RDF File'),
            ('dc:creator', u'Example'), 
            ('dc:description', None),
        )]
        # single result set, query ordered.
        results = self.file.queryDC('')
        self.assertEqual(answer, results)
Exemple #2
0
 def setUp(self):
     self.file = RdfXmlMetadata()