Skip to content

Commit a6240d0

Browse files
committed
chore(Makefile): update test command to use uv run for better compatibility
feat(tests): add test cases for ShellExecutor's pipe command functionality to ensure correct execution and error handling
1 parent bd748f4 commit a6240d0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
.DEFAULT_GOAL := all
33

44
test:
5-
pip install -e .
6-
pytest
5+
uv run pytest
76

87
format:
98
black .

tests/test_shell_executor_pipe.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pytest
2+
3+
from mcp_shell_server.shell_executor import ShellExecutor
4+
5+
6+
@pytest.fixture
7+
def executor():
8+
return ShellExecutor()
9+
10+
11+
@pytest.mark.asyncio
12+
async def test_basic_pipe_command(executor, monkeypatch):
13+
"""Test basic pipe functionality with allowed commands"""
14+
monkeypatch.setenv("ALLOW_COMMANDS", "echo,grep")
15+
result = await executor.execute(["echo", "hello world", "|", "grep", "world"])
16+
assert result["status"] == 0
17+
assert result["stdout"].strip() == "hello world"
18+
19+
20+
@pytest.mark.asyncio
21+
async def test_invalid_pipe_command(executor, monkeypatch):
22+
"""Test pipe command with non-allowed command"""
23+
monkeypatch.setenv("ALLOW_COMMANDS", "echo")
24+
result = await executor.execute(["echo", "hello", "|", "grep", "hello"])
25+
assert result["status"] == 1
26+
assert "Command not allowed: grep" in result["error"]

0 commit comments

Comments
 (0)