Skip to content

Commit 6d5c34c

Browse files
FradSerclaude
andcommitted
refactor: replace run_tests.py with makefile for pytest best practices
- Replace custom test runner with standard Makefile approach - Add comprehensive test targets (unit, integration, security, config) - Include quality checks (mypy, ruff) after successful tests - Restore ThoughtProcessor implementation into server_core.py - Fix integration tests to use proper mocking patterns - Update documentation in CLAUDE.md and READMEs - Add .gitignore rules for temporary test files All 69 tests passing. Follows pytest best practices with direct pytest execution through make targets instead of wrapper scripts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7edb6da commit 6d5c34c

File tree

8 files changed

+323
-223
lines changed

8 files changed

+323
-223
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ wheels/
1717
htmlcov/
1818
.coverage.*
1919
test-results.xml
20+
21+
# Temporary test files in root (avoid creating these)
22+
/test_*.py
23+
/TEST_*.md

CLAUDE.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ uv pip install -e ".[dev]" # Install dependencies
88
uv run mcp-server-mas-sequential-thinking # Run server
99
uv run ruff check . --fix && uv run ruff format . && uv run mypy . # Code quality
1010

11-
# Testing Framework
12-
python run_tests.py # Run all tests with coverage
13-
python run_tests.py --unit --security # Run unit and security tests
14-
uv run pytest tests/ -v # Direct pytest execution
11+
# Testing Framework (using Makefile)
12+
make test # Run all tests with coverage + quality checks
13+
make test-unit # Run unit tests only
14+
make test-fast # Fast run without coverage
15+
make test-parallel # Run tests in parallel
16+
make test-coverage # Generate HTML coverage report
17+
make help # Show all available commands
18+
19+
# Direct Pytest Commands
20+
uv run pytest tests/ -v # Run all tests
21+
uv run pytest -m unit # Run tests with specific marker
22+
uv run pytest --no-cov # Skip coverage
1523

1624
# Debugging & Monitoring
1725
tail -f ~/.sequential_thinking/logs/sequential_thinking.log # Live logs

Makefile

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Makefile for MCP Sequential Thinking Server
2+
# Provides convenient commands for testing and development
3+
4+
.PHONY: help test test-unit test-integration test-security test-config test-fast test-debug test-quiet test-parallel test-coverage test-junit check-types lint check-all clean
5+
6+
# Default target: show help
7+
help:
8+
@echo "MCP Sequential Thinking Server - Test Commands"
9+
@echo ""
10+
@echo "Test Execution:"
11+
@echo " make test - Run all tests with coverage (default)"
12+
@echo " make test-unit - Run only unit tests"
13+
@echo " make test-integration - Run only integration tests"
14+
@echo " make test-security - Run only security tests"
15+
@echo " make test-config - Run only configuration tests"
16+
@echo " make test-fast - Run tests without coverage (faster)"
17+
@echo " make test-debug - Run tests in debug mode (verbose)"
18+
@echo " make test-quiet - Run tests with minimal output"
19+
@echo " make test-parallel - Run tests in parallel"
20+
@echo ""
21+
@echo "Coverage & Reports:"
22+
@echo " make test-coverage - Run tests with HTML coverage report"
23+
@echo " make test-junit - Run tests with JUnit XML report"
24+
@echo ""
25+
@echo "Code Quality:"
26+
@echo " make check-types - Run mypy type checking"
27+
@echo " make lint - Run ruff linting"
28+
@echo " make check-all - Run all quality checks (tests + types + lint)"
29+
@echo ""
30+
@echo "Cleanup:"
31+
@echo " make clean - Remove test artifacts and cache files"
32+
33+
# Run all tests with coverage (default behavior)
34+
test:
35+
@echo "Running all tests with coverage..."
36+
@uv run pytest tests/ --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short
37+
@$(MAKE) -s check-types
38+
@$(MAKE) -s lint
39+
40+
# Run only unit tests
41+
test-unit:
42+
@echo "Running unit tests..."
43+
@uv run pytest tests/unit/ --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short
44+
@$(MAKE) -s check-types
45+
@$(MAKE) -s lint
46+
47+
# Run only integration tests
48+
test-integration:
49+
@echo "Running integration tests..."
50+
@uv run pytest tests/integration/ --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short
51+
@$(MAKE) -s check-types
52+
@$(MAKE) -s lint
53+
54+
# Run only security tests (using markers)
55+
test-security:
56+
@echo "Running security tests..."
57+
@uv run pytest -m security --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short
58+
@$(MAKE) -s check-types
59+
@$(MAKE) -s lint
60+
61+
# Run only configuration tests (using markers)
62+
test-config:
63+
@echo "Running configuration tests..."
64+
@uv run pytest -m config --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short
65+
@$(MAKE) -s check-types
66+
@$(MAKE) -s lint
67+
68+
# Run tests without coverage (faster)
69+
test-fast:
70+
@echo "Running tests without coverage (fast mode)..."
71+
@uv run pytest tests/ -v --tb=short --no-cov
72+
73+
# Run tests in debug mode (verbose, no capture, long tracebacks)
74+
test-debug:
75+
@echo "Running tests in debug mode..."
76+
@uv run pytest tests/ -vv -s --tb=long --no-cov
77+
78+
# Run tests with minimal output
79+
test-quiet:
80+
@echo "Running tests (quiet mode)..."
81+
@uv run pytest tests/ -q --tb=short --no-cov
82+
83+
# Run tests in parallel
84+
test-parallel:
85+
@echo "Running tests in parallel..."
86+
@uv run pytest tests/ --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short -n auto
87+
@$(MAKE) -s check-types
88+
@$(MAKE) -s lint
89+
90+
# Run tests with HTML coverage report
91+
test-coverage:
92+
@echo "Running tests with HTML coverage report..."
93+
@uv run pytest tests/ --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing --cov-report=html -v --tb=short
94+
@echo "Coverage report generated in htmlcov/index.html"
95+
@$(MAKE) -s check-types
96+
@$(MAKE) -s lint
97+
98+
# Run tests with JUnit XML report
99+
test-junit:
100+
@echo "Running tests with JUnit XML report..."
101+
@uv run pytest tests/ --cov=src/mcp_server_mas_sequential_thinking --cov-report=term-missing -v --tb=short --junit-xml=test-results.xml
102+
@echo "JUnit report generated: test-results.xml"
103+
@$(MAKE) -s check-types
104+
@$(MAKE) -s lint
105+
106+
# Run mypy type checking
107+
check-types:
108+
@echo "Type checking with mypy..."
109+
@uv run mypy src --ignore-missing-imports
110+
111+
# Run ruff linting
112+
lint:
113+
@echo "Linting with ruff..."
114+
@uv run ruff check src tests
115+
116+
# Run all quality checks (tests, type checking, linting)
117+
check-all: test check-types lint
118+
@echo "All quality checks passed!"
119+
120+
# Clean up test artifacts and cache files
121+
clean:
122+
@echo "Cleaning test artifacts and cache files..."
123+
@rm -rf .pytest_cache .coverage htmlcov test-results.xml
124+
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
125+
@find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
126+
@find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
127+
@echo "Clean complete!"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ mcp-server-mas-sequential-thinking/
461461
│ │ ├── ai_complexity_analyzer.py # AI-powered analysis
462462
│ │ └── multi_thinking_router.py # Intelligent routing
463463
│ ├── services/
464-
│ │ ├── thought_processor_refactored.py
464+
│ │ ├── server_core.py # ThoughtProcessor implementation
465465
│ │ ├── workflow_executor.py
466466
│ │ └── context_builder.py
467467
│ └── config/

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ mcp-server-mas-sequential-thinking/
461461
│ │ ├── ai_complexity_analyzer.py # AI 驱动分析
462462
│ │ └── multi_thinking_router.py # 智能路由
463463
│ ├── services/
464-
│ │ ├── thought_processor_refactored.py
464+
│ │ ├── server_core.py # ThoughtProcessor 实现
465465
│ │ ├── workflow_executor.py
466466
│ │ └── context_builder.py
467467
│ └── config/

run_tests.py

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)