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

Function test_txt_sitemap

tests/unit/_utils/test_sitemap.py:243–258  ·  view source on GitHub ↗

Test loading a plain text sitemap.

(server_url: URL, http_client: HttpClient)

Source from the content-addressed store, hash-verified

241
242
243async def test_txt_sitemap(server_url: URL, http_client: HttpClient) -> None:
244 """Test loading a plain text sitemap."""
245 urls = [
246 f'{server_url}catalog?item=78&desc=vacation_crete',
247 f'{server_url}catalog?item=79&desc=vacation_somalia',
248 ]
249 txt_sitemap_content = '\n'.join(urls)
250
251 sitemap_url = (server_url / 'sitemap.txt').with_query(base64=encode_base64(txt_sitemap_content.encode()))
252 sitemap = await Sitemap.load(str(sitemap_url), http_client=http_client)
253
254 assert len(sitemap.urls) == 2
255 assert set(sitemap.urls) == {
256 f'{server_url}catalog?item=78&desc=vacation_crete',
257 f'{server_url}catalog?item=79&desc=vacation_somalia',
258 }
259
260
261async def test_sitemap_pretty(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