migration
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
|
||||
from personal_mcp.prompts.content import render_prompt
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
class TestPromptContentRenderer:
|
||||
def test_renders_arguments_without_frontmatter(self) -> None:
|
||||
rendered = render_prompt(
|
||||
"jsfiddle-page-layout",
|
||||
{"domain": "public library", "layout_brief": None},
|
||||
)
|
||||
|
||||
assert not rendered.startswith("---")
|
||||
assert "`domain`: public library" in rendered
|
||||
assert "`layout_brief`: Not provided" in rendered
|
||||
|
||||
def test_rejects_placeholder_drift(self) -> None:
|
||||
with pytest.raises(ValueError, match="placeholders do not match arguments"):
|
||||
render_prompt("jsfiddle-page-layout", {"domain": "public library"})
|
||||
|
||||
def test_rejects_invalid_prompt_id(self) -> None:
|
||||
with pytest.raises(ValueError, match="lowercase kebab-case"):
|
||||
render_prompt("../outside", {})
|
||||
@@ -0,0 +1,52 @@
|
||||
import pytest
|
||||
from fastmcp import Client
|
||||
from fastmcp import FastMCP
|
||||
|
||||
from personal_mcp.prompts import create_prompts_provider
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
EXPECTED_PROMPTS = {
|
||||
"authoring",
|
||||
"greenfield-architecture",
|
||||
"jsfiddle-page-layout",
|
||||
"mcp-consumer-repo-shim",
|
||||
"nicegui-component-extraction",
|
||||
"pytest-fill-scaffold",
|
||||
"pytest-scaffold",
|
||||
}
|
||||
|
||||
|
||||
class TestPromptFileSystemProvider:
|
||||
@pytest.mark.asyncio
|
||||
async def test_discovers_exact_authored_set(self) -> None:
|
||||
mcp = FastMCP("prompts-test")
|
||||
mcp.add_provider(create_prompts_provider())
|
||||
|
||||
async with Client(mcp) as client:
|
||||
prompts = await client.list_prompts()
|
||||
|
||||
assert {prompt.name for prompt in prompts} == EXPECTED_PROMPTS
|
||||
assert all(prompt.description for prompt in prompts)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_exposes_typed_arguments_and_renders_markdown(self) -> None:
|
||||
mcp = FastMCP("prompts-test")
|
||||
mcp.add_provider(create_prompts_provider())
|
||||
|
||||
async with Client(mcp) as client:
|
||||
prompts = await client.list_prompts()
|
||||
authoring = next(prompt for prompt in prompts if prompt.name == "authoring")
|
||||
result = await client.get_prompt(
|
||||
"authoring",
|
||||
{
|
||||
"artifact_type": "skill",
|
||||
"artifact_id": "demo-skill",
|
||||
"goal": "Demonstrate typed prompts.",
|
||||
},
|
||||
)
|
||||
|
||||
required = {argument.name for argument in authoring.arguments or [] if argument.required}
|
||||
assert required == {"artifact_type", "artifact_id", "goal"}
|
||||
assert result.messages
|
||||
assert "`artifact_id`: demo-skill" in result.messages[0].content.text
|
||||
Reference in New Issue
Block a user