Example #1
0
 def test_21_parse_sitemapindex(self):
     s=Sitemap()
     si = s.sitemapindex_parse_xml( fh=StringIO.StringIO('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>aaa</loc></sitemap><sitemap><loc>bbb</loc></sitemap></sitemapindex>') )
     self.assertEqual( s.sitemaps_created, 2, '2 sitemaps in sitemapindex')
     self.assertEqual( len(si.resources), 2, '2 sitemaps')
     sms = sorted(si.resources.keys())
     self.assertEqual( sms, ['aaa','bbb'] )
     # add a couple more
     s.sitemapindex_parse_xml( fh=StringIO.StringIO('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>cc</loc></sitemap><sitemap><loc>dd</loc></sitemap></sitemapindex>'), sitemapindex=si )
     self.assertEqual( s.sitemaps_created, 2, '2 sitemaps created to sitemapindex')
     self.assertEqual( len(si.resources), 4, '4 sitemaps total')
     sms = sorted(si.resources.keys())
     self.assertEqual( sms, ['aaa','bbb', 'cc', 'dd'] )
Example #2
0
 def test_21_parse_sitemapindex(self):
     s=Sitemap()
     si = s.sitemapindex_parse_xml( fh=StringIO.StringIO('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>aaa</loc></sitemap><sitemap><loc>bbb</loc></sitemap></sitemapindex>') )
     self.assertEqual( s.sitemaps_created, 2, '2 sitemaps in sitemapindex')
     self.assertEqual( len(si.resources), 2, '2 sitemaps')
     sms = sorted(si.resources.keys())
     self.assertEqual( sms, ['aaa','bbb'] )
     # add a couple more
     s.sitemapindex_parse_xml( fh=StringIO.StringIO('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>cc</loc></sitemap><sitemap><loc>dd</loc></sitemap></sitemapindex>'), sitemapindex=si )
     self.assertEqual( s.sitemaps_created, 2, '2 sitemaps created to sitemapindex')
     self.assertEqual( len(si.resources), 4, '4 sitemaps total')
     sms = sorted(si.resources.keys())
     self.assertEqual( sms, ['aaa','bbb', 'cc', 'dd'] )
Example #3
0
 def test_20_parse_sitemapindex_empty(self):
     s = Sitemap()
     si = s.sitemapindex_parse_xml(
         fh=StringIO.StringIO('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> </sitemapindex>')
     )
     self.assertEqual(s.sitemaps_created, 0, "0 sitemaps in sitemapindex")
     self.assertEqual(len(si.resources), 0, "0 sitemaps")
Example #4
0
 def test_22_parse_sitemapindex_file(self):
     s=Sitemap()
     fh=open('resync/test/testdata/sitemapindex1/sitemap.xml')
     si = s.sitemapindex_parse_xml( fh=fh )
     self.assertEqual( s.sitemaps_created, 3, '3 sitemaps in sitemapindex')
     self.assertEqual( len(si.resources), 3, '3 sitemaps')
     sms = sorted(si.resources.keys())
     self.assertEqual( sms, ['http://localhost:8888/sitemap00000.xml','http://localhost:8888/sitemap00001.xml','http://localhost:8888/sitemap00002.xml'] )
     self.assertEqual( si.resources['http://localhost:8888/sitemap00000.xml'].lastmod, '2012-06-13T18:09:13' )
Example #5
0
 def test_22_parse_sitemapindex_file(self):
     s=Sitemap()
     fh=open('resync/test/testdata/sitemapindex1/sitemap.xml')
     si = s.sitemapindex_parse_xml( fh=fh )
     self.assertEqual( s.sitemaps_created, 3, '3 sitemaps in sitemapindex')
     self.assertEqual( len(si.resources), 3, '3 sitemaps')
     sms = sorted(si.resources.keys())
     self.assertEqual( sms, ['http://localhost:8888/sitemap00000.xml','http://localhost:8888/sitemap00001.xml','http://localhost:8888/sitemap00002.xml'] )
     self.assertEqual( si.resources['http://localhost:8888/sitemap00000.xml'].lastmod, '2012-06-13T18:09:13Z' )
Example #6
0
 def test_21_parse_sitemapindex(self):
     s = Sitemap()
     si = s.sitemapindex_parse_xml(
         fh=StringIO.StringIO(
             '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>aaa</loc></sitemap><sitemap><loc>bbb</loc></sitemap></sitemapindex>'
         )
     )
     self.assertEqual(s.sitemaps_created, 2, "2 sitemaps in sitemapindex")
     self.assertEqual(len(si.resources), 2, "2 sitemaps")
     sms = sorted(si.resources.keys())
     self.assertEqual(sms, ["aaa", "bbb"])
     # add a couple more
     s.sitemapindex_parse_xml(
         fh=StringIO.StringIO(
             '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>cc</loc></sitemap><sitemap><loc>dd</loc></sitemap></sitemapindex>'
         ),
         sitemapindex=si,
     )
     self.assertEqual(s.sitemaps_created, 2, "2 sitemaps created to sitemapindex")
     self.assertEqual(len(si.resources), 4, "4 sitemaps total")
     sms = sorted(si.resources.keys())
     self.assertEqual(sms, ["aaa", "bbb", "cc", "dd"])
Example #7
0
 def test_22_parse_sitemapindex_file(self):
     s = Sitemap()
     fh = open("resync/test/testdata/sitemapindex1/sitemap.xml")
     si = s.sitemapindex_parse_xml(fh=fh)
     self.assertEqual(s.sitemaps_created, 3, "3 sitemaps in sitemapindex")
     self.assertEqual(len(si.resources), 3, "3 sitemaps")
     sms = sorted(si.resources.keys())
     self.assertEqual(
         sms,
         [
             "http://localhost:8888/sitemap00000.xml",
             "http://localhost:8888/sitemap00001.xml",
             "http://localhost:8888/sitemap00002.xml",
         ],
     )
     self.assertEqual(si.resources["http://localhost:8888/sitemap00000.xml"].lastmod, "2012-06-13T18:09:13")
Example #8
0
 def test_20_parse_sitemapindex_empty(self):
     s=Sitemap()
     si = s.sitemapindex_parse_xml( fh=StringIO.StringIO('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> </sitemapindex>') )
     self.assertEqual( s.sitemaps_created, 0, '0 sitemaps in sitemapindex')
     self.assertEqual( len(si.resources), 0, '0 sitemaps')