open-swe/tests/test_api_standards_skill.py
GowriH-1 85049290a3
feat: apply API standards skill in PR reviews for API changes (#1452)
Pull the api-standards skill from the LangSmith Context Hub at reviewer
run start and inject it into the system prompt, gated on the PR adding or
modifying an API surface. Best-effort: failures fall back to no supplement.

Co-authored-by: GowriH-1 <218394553+GowriH-1@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-08 14:37:04 -07:00

35 lines
1.1 KiB
Python

from __future__ import annotations
from unittest.mock import patch
import pytest
from agent.utils import api_standards_skill
@pytest.mark.asyncio
async def test_fetch_returns_skill_content() -> None:
with patch.object(
api_standards_skill,
"_pull_api_standards_skill_sync",
return_value="Use /v1/ prefixes.",
):
content = await api_standards_skill.fetch_api_standards_skill("api-standards")
assert content == "Use /v1/ prefixes."
@pytest.mark.asyncio
async def test_fetch_returns_none_on_error() -> None:
def _boom(_handle: str) -> str | None:
raise RuntimeError("no api key")
with patch.object(api_standards_skill, "_pull_api_standards_skill_sync", side_effect=_boom):
content = await api_standards_skill.fetch_api_standards_skill("api-standards")
assert content is None
@pytest.mark.asyncio
async def test_fetch_returns_none_when_no_handle_configured() -> None:
with patch.object(api_standards_skill, "API_STANDARDS_SKILL_HANDLE", ""):
content = await api_standards_skill.fetch_api_standards_skill("")
assert content is None