0226e33ac7
- port of the wiki-local linux-server-hardening checklist (v1.2.0) into the bundle: audit listeners and accounts, SSH key-only, close unused accounts, scoped firewall, fail2ban, unattended-upgrades, surface reduction, verify-and-record; new `security` category, announced live by the listing per CONTRIBUTING - SKILL.md body ported verbatim from the source copy; front matter adapted to the four-key bundle contract (SPEC 4.2-4.3) - MEMORIES.md starting template shipped beside it (SPEC 4.7); the installed memory is add-only so live instances keep their entries (SPEC 6.8) - tests: bundled load, category listing, and category filter for the new skill; autotest fully green (84 tests, 93 percent coverage); e2e-verified via the installed pipx CLI Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
"""Registry tests: front matter contract and the bundled SKILLS scan (SPEC section 4)."""
|
|
import pytest
|
|
|
|
from phronesis import registry
|
|
|
|
GOOD = """---
|
|
name: python-tdd
|
|
version: 1.2.0
|
|
description: Minimalist TDD architect for Python work
|
|
category: development
|
|
---
|
|
"""
|
|
BAD_VERSION = GOOD.replace("1.2.0", "1.2")
|
|
BAD_CATEGORY = GOOD.replace("development", "Development")
|
|
|
|
|
|
def test_parse_frontmatter_reads_every_key():
|
|
data = registry.parse_frontmatter(GOOD)
|
|
assert data["name"] == "python-tdd"
|
|
assert data["version"] == "1.2.0"
|
|
assert data["category"] == "development"
|
|
|
|
|
|
@pytest.mark.parametrize("text", [
|
|
"no front matter at all",
|
|
GOOD.replace("---\n", "", 1),
|
|
"---\nname: x\nversion: 1.0.0\n",
|
|
BAD_VERSION,
|
|
BAD_CATEGORY,
|
|
])
|
|
def test_parse_frontmatter_rejects_malformed(text):
|
|
with pytest.raises(registry.RegistryError):
|
|
registry.parse_frontmatter(text)
|
|
|
|
|
|
def test_skills_loads_the_bundled_python_tdd():
|
|
assert "python-tdd" in registry.SKILLS
|
|
skill = registry.SKILLS["python-tdd"]
|
|
assert skill.version == "1.2.0"
|
|
assert skill.category == "development"
|
|
assert skill.description
|
|
assert (skill.source_dir / "SKILL.md").is_file()
|
|
|
|
|
|
def test_skills_loads_the_bundled_linux_server_hardening():
|
|
assert "linux-server-hardening" in registry.SKILLS
|
|
skill = registry.SKILLS["linux-server-hardening"]
|
|
assert skill.version == "1.2.0"
|
|
assert skill.category == "security"
|
|
assert skill.description
|
|
assert (skill.source_dir / "SKILL.md").is_file()
|
|
assert (skill.source_dir / "MEMORIES.md").is_file()
|
|
|
|
|
|
def test_categories_list_the_packed_skills():
|
|
assert "python-tdd" in registry.CATEGORIES[registry.SKILLS["python-tdd"].category]
|
|
assert "linux-server-hardening" in registry.CATEGORIES["security"]
|
|
|
|
|
|
def test_skills_in_category_filters_by_label():
|
|
assert registry.skills_in_category("development") == {"python-tdd": registry.SKILLS["python-tdd"]}
|
|
assert registry.skills_in_category("security") == {
|
|
"linux-server-hardening": registry.SKILLS["linux-server-hardening"],
|
|
}
|
|
assert registry.skills_in_category("nonesuch") == {}
|