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

Function test_extract_metadata_sitemap

tests/unit/_utils/test_sitemap.py:115–129  ·  view source on GitHub ↗

Test extracting item metadata from a sitemap.

(server_url: URL, http_client: HttpClient)

Source from the content-addressed store, hash-verified

113
114
115async def test_extract_metadata_sitemap(server_url: URL, http_client: HttpClient) -> None:
116 """Test extracting item metadata from a sitemap."""
117 sitemap_url = (server_url / 'sitemap.xml').with_query(
118 base64=encode_base64(get_basic_sitemap(url=server_url).encode()), c_type='application/xml; charset=utf-8'
119 )
120
121 items = [item async for item in parse_sitemap([{'type': 'url', 'url': str(sitemap_url)}], http_client=http_client)]
122 assert len(items) == 5
123 assert items[0] == SitemapUrl(
124 loc=str(server_url),
125 priority=0.8,
126 changefreq='monthly',
127 lastmod=datetime.fromisoformat('2005-02-03'),
128 origin_sitemap_url=str(sitemap_url),
129 )
130
131
132async def test_gzipped_sitemap(server_url: URL, http_client: HttpClient) -> None:

Callers

nothing calls this directly

Calls 4

get_basic_sitemapFunction · 0.90
parse_sitemapFunction · 0.90
SitemapUrlClass · 0.90
encode_base64Function · 0.70

Tested by

no test coverage detected