MCPcopy Create free account
hub / github.com/apify/crawlee-python / test_cdata_sitemap

Function test_cdata_sitemap

tests/unit/_utils/test_sitemap.py:224–240  ·  view source on GitHub ↗

Test loading a sitemap with CDATA sections.

(server_url: URL, http_client: HttpClient)

Source from the content-addressed store, hash-verified

222
223
224async def test_cdata_sitemap(server_url: URL, http_client: HttpClient) -> None:
225 """Test loading a sitemap with CDATA sections."""
226 cdata_sitemap = f"""
227<?xml version="1.0" encoding="UTF-8"?>
228<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
229<url>
230<loc><![CDATA[{server_url}catalog]]></loc>
231</url>
232</urlset>
233 """.strip()
234 sitemap_url = (server_url / 'sitemap.xml').with_query(
235 base64=encode_base64(cdata_sitemap.encode()), c_type='application/xml; charset=utf-8'
236 )
237 sitemap = await Sitemap.load(str(sitemap_url), http_client=http_client)
238
239 assert len(sitemap.urls) == 1
240 assert sitemap.urls == [f'{server_url}catalog']
241
242
243async def test_txt_sitemap(server_url: URL, http_client: HttpClient) -> None:

Callers

nothing calls this directly

Calls 2

encode_base64Function · 0.70
loadMethod · 0.45

Tested by

no test coverage detected