コード例 #1
0
 def test_ex_03(self):
     """resourcesync_ex_3 is a simple change_list with 2 resources"""
     cl=ChangeList()
     cl.parse('tests/testdata/examples_from_spec/resourcesync_ex_3.xml')
     self.assertEqual( len(cl.resources), 2, '2 resources')
     sms = sorted(cl.uris())
     self.assertEqual( sms, ['http://example.com/res2.pdf','http://example.com/res3.tiff'] )
     self.assertEqual( cl.resources[0].lastmod, '2013-01-02T13:00:00Z' )
     self.assertEqual( cl.resources[1].lastmod, '2013-01-02T18:00:00Z' )
     self.assertEqual( cl.resources[0].change, 'updated' )
     self.assertEqual( cl.resources[1].change, 'deleted' )
コード例 #2
0
    def test08_parse(self):
        xml='<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n\
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:rs="http://www.openarchives.org/rs/terms/">\
<rs:md capability="changelist" from="2013-01-01"/>\
<url><loc>/tmp/rs_test/src/file_a</loc><lastmod>2012-03-14T18:37:36Z</lastmod><rs:md change="updated" length="12" /></url>\
<url><loc>/tmp/rs_test/src/file_b</loc><lastmod>2012-03-14T18:37:36Z</lastmod><rs:md change="deleted" length="32" /></url>\
</urlset>'
        cl=ChangeList()
        cl.parse(fh=io.StringIO(xml))
        self.assertEqual( len(cl.resources), 2, 'got 2 resources')
        self.assertEqual( cl.md['capability'], 'changelist', 'capability set' )
        self.assertEqual( cl.md['md_from'], '2013-01-01' )