mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-20 19:52:23 +02:00
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""A paste that is not a skills install must return None, not a guess.
|
|
|
|
`npx create-react-app foo` parsed as the skill id "create-react-app" until 2026-08-07: any unrelated
|
|
npx command a user pasted would have installed a skill by that name. The module's own docstring says
|
|
None means "I could not read this", never a guess, so the registry name is now required."""
|
|
|
|
import pytest
|
|
|
|
from backend.apps.skill_registry.parse_install_command import parse_install_command
|
|
|
|
REAL_INSTALLS = [
|
|
("npx skills add pdf-filler", "pdf-filler"),
|
|
("$ npx skills add pdf-filler", "pdf-filler"),
|
|
("npm i skills pdf-filler", "pdf-filler"),
|
|
("bunx skills install pdf-filler", "pdf-filler"),
|
|
("pnpm skills add @acme/pdf-filler", "@acme/pdf-filler"),
|
|
("npx skills add pdf-filler --force", "pdf-filler"),
|
|
("https://skills.sh/s/pdf-filler", "pdf-filler"),
|
|
("pdf-filler", "pdf-filler"),
|
|
]
|
|
|
|
NOT_INSTALLS = [
|
|
"npx create-react-app foo",
|
|
"npm i lodash",
|
|
"npx vite build",
|
|
"yarn add react",
|
|
"rm -rf /",
|
|
"",
|
|
" ",
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("raw,expected", REAL_INSTALLS)
|
|
def test_the_forms_people_actually_paste_still_parse(raw, expected):
|
|
assert parse_install_command(raw) == expected
|
|
|
|
|
|
@pytest.mark.parametrize("raw", NOT_INSTALLS)
|
|
def test_anything_that_is_not_a_skills_install_is_refused(raw):
|
|
assert parse_install_command(raw) is None, f"{raw!r} must not be read as a skill id"
|