Example #1
0
 def test_04_resource_str(self):
     r1 = Resource(uri='4a',lastmod="2013-01-02",length=9999,md5='ab54de')
     r1.ln = [{ 'rel':'duplicate',
                'pri':'1',
                'href':'http://mirror1.example.com/res1',
                'modified':'2013-01-02T18:00:00Z' }]
     self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>4a</loc><lastmod>2013-01-02T00:00:00Z</lastmod><rs:md hash=\"md5:ab54de\" length=\"9999\" /><rs:ln href=\"http://mirror1.example.com/res1\" modified=\"2013-01-02T18:00:00Z\" pri=\"1\" rel=\"duplicate\" /></url>" )
     # add another two rs:ln's
     r1.ln.append( { 'rel':'num2' } )
     r1.ln.append( { 'rel':'num3' } )
     self.assertEqual( Sitemap().resource_as_xml(r1), "<url><loc>4a</loc><lastmod>2013-01-02T00:00:00Z</lastmod><rs:md hash=\"md5:ab54de\" length=\"9999\" /><rs:ln href=\"http://mirror1.example.com/res1\" modified=\"2013-01-02T18:00:00Z\" pri=\"1\" rel=\"duplicate\" /><rs:ln rel=\"num2\" /><rs:ln rel=\"num3\" /></url>" )
Example #2
0
 def test_04_resource_str(self):
     r1 = Resource(uri='4a',
                   lastmod="2013-01-02",
                   length=9999,
                   md5='ab54de')
     r1.ln = [{
         'rel': 'duplicate',
         'pri': '1',
         'href': 'http://mirror1.example.com/res1',
         'modified': '2013-01-02T18:00:00Z'
     }]
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<url><loc>4a</loc><lastmod>2013-01-02T00:00:00Z</lastmod><rs:md hash=\"md5:ab54de\" length=\"9999\" /><rs:ln href=\"http://mirror1.example.com/res1\" modified=\"2013-01-02T18:00:00Z\" pri=\"1\" rel=\"duplicate\" /></url>"
     )
     # add another two rs:ln's
     r1.ln.append({'rel': 'num2'})
     r1.ln.append({'rel': 'num3'})
     self.assertEqual(
         Sitemap().resource_as_xml(r1),
         "<url><loc>4a</loc><lastmod>2013-01-02T00:00:00Z</lastmod><rs:md hash=\"md5:ab54de\" length=\"9999\" /><rs:ln href=\"http://mirror1.example.com/res1\" modified=\"2013-01-02T18:00:00Z\" pri=\"1\" rel=\"duplicate\" /><rs:ln rel=\"num2\" /><rs:ln rel=\"num3\" /></url>"
     )