test(cron): cover absolute skill path normalization (#59824)

Add unit tests for normalize_skill_lookup_name and a cron scheduler
regression that absolute paths under the skills dir reach skill_view as
relative lookups.
This commit is contained in:
HexLab98 2026-07-07 02:59:03 +07:00 committed by kshitij
parent 62972060ca
commit e7082ea99f
2 changed files with 64 additions and 0 deletions

View file

@ -2885,6 +2885,31 @@ class TestBuildJobPromptMissingSkill:
assert "go" in result
class TestBuildJobPromptAbsoluteSkillPath:
"""Cron jobs may store absolute skill paths; normalize before skill_view."""
def test_absolute_skill_path_normalized_before_skill_view(self, tmp_path):
skills_dir = tmp_path / "skills"
skill_dir = skills_dir / "alpha-skill"
skill_dir.mkdir(parents=True)
(skill_dir / "SKILL.md").write_text("# Alpha\nDo alpha.")
absolute_path = str(skill_dir)
seen_names: list[str] = []
def _skill_view(name: str) -> str:
seen_names.append(name)
if name == "alpha-skill":
return json.dumps({"success": True, "content": "# Alpha\nDo alpha."})
return json.dumps({"success": False, "error": f"Skill '{name}' not found."})
with patch("agent.skill_utils.get_skills_dir", return_value=skills_dir), \
patch("tools.skills_tool.skill_view", side_effect=_skill_view):
result = _build_job_prompt({"skills": [absolute_path], "prompt": "go"})
assert seen_names == ["alpha-skill"]
assert "Do alpha." in result
class TestBuildJobPromptBumpUse:
"""Verify that cron jobs bump skill usage counters so the curator sees them as active."""