def test_sitemap_to_xml(self): assert SitemapMixin.to_sitemap_xml( "http://example.com", False) == "<url><loc>http://example.com</loc></url>" assert SitemapMixin.to_sitemap_xml("http://example.com").startswith( "<url><loc>http://example.com</loc><lastmod>") assert "<lastmod>2012-01-01</lastmod>" in SitemapMixin.to_sitemap_xml( "http://example.com", datetime(2012, 1, 1)) assert "<changefreq>daily</changefreq>" in SitemapMixin.to_sitemap_xml( "http://example.com", False, "daily") assert "<priority>1.0</priority>" in SitemapMixin.to_sitemap_xml( "http://example.com", False, priority=1.0)
def test_attributes(self): with pytest.raises(NotImplementedError): SitemapMixin().loc
def test_sitemap_escaping(self): """ http://www.sitemaps.org/protocol.html#escaping """ assert SitemapMixin.to_sitemap_xml( "http://example.com/&\'\"><", False ) == "<url><loc>http://example.com/&'"><</loc></url>"
def test_sitemap_escaping(self): """ http://www.sitemaps.org/protocol.html#escaping """ assert SitemapMixin.to_sitemap_xml("http://example.com/&\'\"><", False) == "<url><loc>http://example.com/&'"><</loc></url>"
def test_sitemap_to_xml(self): assert SitemapMixin.to_sitemap_xml("http://example.com", False) == "<url><loc>http://example.com</loc></url>" assert SitemapMixin.to_sitemap_xml("http://example.com").startswith("<url><loc>http://example.com</loc><lastmod>") assert "<lastmod>2012-01-01</lastmod>" in SitemapMixin.to_sitemap_xml("http://example.com", datetime(2012,1,1)) assert "<changefreq>daily</changefreq>" in SitemapMixin.to_sitemap_xml("http://example.com", False, "daily") assert "<priority>1.0</priority>" in SitemapMixin.to_sitemap_xml("http://example.com", False, priority=1.0)