diff --git a/tests/tools/test_skills_hub.py b/tests/tools/test_skills_hub.py
index 32e759998f..b7631b4d73 100644
--- a/tests/tools/test_skills_hub.py
+++ b/tests/tools/test_skills_hub.py
@@ -258,23 +258,29 @@ class TestSkillsShSource:
@patch("tools.skills_hub._write_index_cache")
@patch("tools.skills_hub._read_index_cache", return_value=None)
def test_sitemap_catalog_retries_failed_shard_and_never_caches_partial(
- self, _mock_read_cache, mock_write_cache, _mock_sleep,
+ self, _mock_read_cache, mock_write_cache, _mock_sleep, monkeypatch,
):
"""A per-skill sitemap shard that keeps failing is a hole in the catalog, not an
empty shard: retry it, and never publish the partial slice to the shared cache."""
+ monkeypatch.setattr("tools.skills_hub.is_safe_url", lambda _url: True)
+ monkeypatch.setattr("tools.skills_hub.check_website_access", lambda _url: None)
+ monkeypatch.setattr("tools.skills_hub_skillssh._cached_metas", lambda _key: None)
+ monkeypatch.setattr("tools.skills_hub_skillssh._cache_metas", lambda _key, _metas: None)
index = ("https://www.skills.sh/sitemap-skills-0.xml"
"https://www.skills.sh/sitemap-skills-1.xml")
shard0 = "https://www.skills.sh/o/r/skill-a"
calls: List[str] = []
- def fake_get_text(url, **kwargs):
+ def fake_get(url, *, timeout, headers=None):
calls.append(url)
if url.endswith("sitemap.xml"):
- return index
- return shard0 if url.endswith("sitemap-skills-0.xml") else None
+ return MagicMock(status_code=200, headers={}, text=index)
+ if url.endswith("sitemap-skills-0.xml"):
+ return MagicMock(status_code=200, headers={}, text=shard0)
+ return MagicMock(status_code=503, headers={}, text="")
- with patch("tools.skills_hub_skillssh._get_text", side_effect=fake_get_text):
- results = self._source()._sitemap_catalog(0)
+ monkeypatch.setattr("tools.skills_hub._ssrf_safe_http_get", fake_get)
+ results = self._source()._sitemap_catalog(0)
assert [m.identifier for m in results] == ["skills-sh/o/r/skill-a"]
assert calls.count("https://www.skills.sh/sitemap-skills-1.xml") == SkillSource.CATALOG_PAGE_RETRIES
diff --git a/tools/skills_hub_skillssh.py b/tools/skills_hub_skillssh.py
index a5cd8cd777..7a3fe96f3f 100644
--- a/tools/skills_hub_skillssh.py
+++ b/tools/skills_hub_skillssh.py
@@ -139,7 +139,7 @@ class SkillsShSource(SkillSource):
return self._featured_skills(limit)
# Step 2: collect canonical "owner/repo/skill" IDs from each sitemap. A shard
- # ``_get_text`` returns None for is a hole, not an empty shard: retry it, and
+ # ``_xml`` returns None for is a hole, not an empty shard: retry it, and
# if it stays dark return the partial slice without publishing it to the cache.
seen, results, partial = set(), [], False
for sitemap_url in skill_sitemap_urls: