38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from pathlib import PurePosixPath
|
|
|
|
import pytest
|
|
from personal_mcp.registry.models.registry import DocsRegistry
|
|
|
|
from personal_mcp.registry.load import read_docs_markdown_path
|
|
|
|
pytestmark = pytest.mark.unit
|
|
|
|
|
|
def _make_registry() -> DocsRegistry:
|
|
index_path = PurePosixPath("index.md")
|
|
return DocsRegistry(
|
|
docs_markdown_by_path={index_path: "# index"},
|
|
docs_markdown_path_index=(index_path,),
|
|
)
|
|
|
|
|
|
def test_reads_docs_path_from_string_boundary() -> None:
|
|
payload = read_docs_markdown_path(_make_registry(), "index.md")
|
|
|
|
assert payload == {
|
|
"uri": "resource://docs/index.md",
|
|
"format": "markdown",
|
|
"source_path": "docs/index.md",
|
|
"content": "# index",
|
|
}
|
|
|
|
|
|
def test_rejects_skill_docs_path() -> None:
|
|
with pytest.raises(KeyError, match="unknown docs path"):
|
|
read_docs_markdown_path(_make_registry(), "skills/demo/SKILL.md")
|
|
|
|
|
|
def test_rejects_non_posix_docs_path() -> None:
|
|
with pytest.raises(ValueError, match="POSIX separators"):
|
|
read_docs_markdown_path(_make_registry(), "guides\\demo.md")
|