Skip to content

Commit f6ca126

Browse files
committed
reorg tests
1 parent fcda14a commit f6ca126

21 files changed

Lines changed: 2891 additions & 56 deletions

.github/workflows/ci.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI Quick Checks
22

33
on:
44
push:
@@ -7,24 +7,15 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
test:
10+
quick-validation:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
14+
python-version: [3.8, "3.11"] # Test oldest and newest
1515

1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Set up R
20-
uses: r-lib/actions/setup-r@v2
21-
with:
22-
r-version: 'release'
23-
24-
- name: Install R packages
25-
run: |
26-
R -e "install.packages(c('plm', 'lmtest', 'sandwich', 'AER', 'jsonlite', 'forecast', 'dplyr', 'tseries', 'nortest', 'car', 'rpart', 'randomForest', 'vars', 'ggplot2', 'gridExtra', 'tidyr', 'rlang', 'urca'), repos='https://cran.rstudio.com/')"
27-
2819
- name: Set up Python ${{ matrix.python-version }}
2920
uses: actions/setup-python@v4
3021
with:
@@ -41,17 +32,17 @@ jobs:
4132
rmcp --version
4233
rmcp list-capabilities > /dev/null
4334
44-
- name: Run basic tests
45-
run: |
46-
python tests/test_server_basic.py
47-
48-
- name: Run MCP interface tests
49-
run: |
50-
python tests/test_mcp_interface.py
51-
52-
- name: Run realistic scenarios
35+
- name: Quick smoke test
5336
run: |
54-
python tests/realistic_scenarios.py
37+
python -c "
38+
import sys
39+
sys.path.insert(0, '.')
40+
from rmcp.core.server import create_server
41+
from rmcp.cli import _register_builtin_tools
42+
server = create_server()
43+
_register_builtin_tools(server)
44+
print('✅ Server can be created and tools registered')
45+
"
5546
5647
lint:
5748
runs-on: ubuntu-latest

.github/workflows/test.yml

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
name: RMCP Test Suite
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.8, 3.9, "3.10", "3.11"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Set up R
26+
uses: r-lib/actions/setup-r@v2
27+
with:
28+
r-version: release
29+
30+
- name: Install R packages
31+
run: |
32+
R -e "install.packages(c('jsonlite', 'plm', 'lmtest', 'sandwich', 'AER', 'dplyr', 'forecast', 'vars', 'urca', 'tseries', 'nortest', 'car', 'rpart', 'randomForest', 'ggplot2', 'gridExtra', 'tidyr', 'rlang', 'readxl'), repos='https://cran.rstudio.com/')"
33+
34+
- name: Install Python dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install click jsonschema pytest pytest-asyncio
38+
39+
- name: Run unit tests
40+
run: |
41+
python -m pytest tests/unit/ -v
42+
43+
- name: Test new tools specifically
44+
run: |
45+
python tests/unit/test_new_tools.py
46+
47+
integration-tests:
48+
name: Integration Tests
49+
runs-on: ubuntu-latest
50+
needs: unit-tests
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Set up Python 3.10
56+
uses: actions/setup-python@v4
57+
with:
58+
python-version: "3.10"
59+
60+
- name: Set up R
61+
uses: r-lib/actions/setup-r@v2
62+
with:
63+
r-version: release
64+
65+
- name: Install R packages
66+
run: |
67+
R -e "install.packages(c('jsonlite', 'plm', 'lmtest', 'sandwich', 'AER', 'dplyr', 'forecast', 'vars', 'urca', 'tseries', 'nortest', 'car', 'rpart', 'randomForest', 'ggplot2', 'gridExtra', 'tidyr', 'rlang', 'readxl'), repos='https://cran.rstudio.com/')"
68+
69+
- name: Install Python dependencies
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install click jsonschema pytest pytest-asyncio
73+
74+
- name: Run MCP interface tests
75+
run: |
76+
python tests/integration/test_mcp_interface.py
77+
78+
- name: Run direct capabilities tests
79+
run: |
80+
python tests/integration/test_direct_capabilities.py
81+
82+
- name: Run new features integration tests
83+
run: |
84+
python tests/integration/test_new_features_integration.py
85+
86+
e2e-tests:
87+
name: End-to-End Tests
88+
runs-on: ubuntu-latest
89+
needs: integration-tests
90+
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Set up Python 3.10
95+
uses: actions/setup-python@v4
96+
with:
97+
python-version: "3.10"
98+
99+
- name: Set up R
100+
uses: r-lib/actions/setup-r@v2
101+
with:
102+
r-version: release
103+
104+
- name: Install R packages
105+
run: |
106+
R -e "install.packages(c('jsonlite', 'plm', 'lmtest', 'sandwich', 'AER', 'dplyr', 'forecast', 'vars', 'urca', 'tseries', 'nortest', 'car', 'rpart', 'randomForest', 'ggplot2', 'gridExtra', 'tidyr', 'rlang', 'readxl'), repos='https://cran.rstudio.com/')"
107+
108+
- name: Install Python dependencies
109+
run: |
110+
python -m pip install --upgrade pip
111+
pip install click jsonschema pytest pytest-asyncio
112+
113+
- name: Run realistic scenarios
114+
run: |
115+
python tests/e2e/realistic_scenarios.py
116+
117+
- name: Run Claude Desktop scenarios
118+
run: |
119+
python tests/e2e/test_claude_desktop_scenarios.py
120+
121+
- name: Run Docker simulation tests
122+
run: |
123+
python tests/e2e/test_docker_simulation.py
124+
125+
tool-count-verification:
126+
name: Verify Tool Count
127+
runs-on: ubuntu-latest
128+
needs: unit-tests
129+
130+
steps:
131+
- uses: actions/checkout@v4
132+
133+
- name: Set up Python 3.10
134+
uses: actions/setup-python@v4
135+
with:
136+
python-version: "3.10"
137+
138+
- name: Set up R
139+
uses: r-lib/actions/setup-r@v2
140+
with:
141+
r-version: release
142+
143+
- name: Install R packages
144+
run: |
145+
R -e "install.packages(c('jsonlite', 'plm', 'lmtest', 'sandwich', 'AER', 'dplyr'), repos='https://cran.rstudio.com/')"
146+
147+
- name: Install Python dependencies
148+
run: |
149+
python -m pip install --upgrade pip
150+
pip install click jsonschema
151+
152+
- name: Verify tool registration count
153+
run: |
154+
python -c "
155+
import sys
156+
sys.path.insert(0, '.')
157+
from rmcp.core.server import create_server
158+
from rmcp.cli import _register_builtin_tools
159+
server = create_server()
160+
_register_builtin_tools(server)
161+
import asyncio
162+
async def count():
163+
ctx = server.create_context('test', 'tools/list')
164+
result = await server.tools.list_tools(ctx)
165+
count = len(result['tools'])
166+
print(f'Registered tools: {count}')
167+
assert count >= 39, f'Expected at least 39 tools, got {count}'
168+
print('✅ Tool count verification passed')
169+
asyncio.run(count())
170+
"
171+
172+
# New feature verification
173+
new-features-smoke-test:
174+
name: New Features Smoke Test
175+
runs-on: ubuntu-latest
176+
needs: unit-tests
177+
178+
steps:
179+
- uses: actions/checkout@v4
180+
181+
- name: Set up Python 3.10
182+
uses: actions/setup-python@v4
183+
with:
184+
python-version: "3.10"
185+
186+
- name: Set up R
187+
uses: r-lib/actions/setup-r@v2
188+
with:
189+
r-version: release
190+
191+
- name: Install R packages
192+
run: |
193+
R -e "install.packages(c('jsonlite', 'dplyr'), repos='https://cran.rstudio.com/')"
194+
195+
- name: Install Python dependencies
196+
run: |
197+
python -m pip install --upgrade pip
198+
pip install click jsonschema
199+
200+
- name: Test formula builder
201+
run: |
202+
python -c "
203+
import sys, asyncio, json
204+
sys.path.insert(0, '.')
205+
from rmcp.core.server import create_server
206+
from rmcp.registries.tools import register_tool_functions
207+
from rmcp.tools.formula_builder import build_formula
208+
from rmcp.tools.helpers import suggest_fix, load_example
209+
210+
async def test():
211+
server = create_server()
212+
register_tool_functions(server.tools, build_formula, suggest_fix, load_example)
213+
214+
# Test formula building
215+
req = {'jsonrpc': '2.0', 'id': 1, 'method': 'tools/call', 'params': {'name': 'build_formula', 'arguments': {'description': 'predict sales from marketing'}}}
216+
resp = await server.handle_request(req)
217+
result = json.loads(resp['result']['content'][0]['text'])
218+
assert 'formula' in result
219+
print(f'✅ Formula builder: {result[\"formula\"]}')
220+
221+
# Test error recovery
222+
req = {'jsonrpc': '2.0', 'id': 2, 'method': 'tools/call', 'params': {'name': 'suggest_fix', 'arguments': {'error_message': 'there is no package called \"forecast\"'}}}
223+
resp = await server.handle_request(req)
224+
result = json.loads(resp['result']['content'][0]['text'])
225+
assert result['error_type'] == 'missing_package'
226+
print(f'✅ Error recovery: {result[\"error_type\"]}')
227+
228+
# Test example datasets
229+
req = {'jsonrpc': '2.0', 'id': 3, 'method': 'tools/call', 'params': {'name': 'load_example', 'arguments': {'dataset_name': 'sales', 'size': 'small'}}}
230+
resp = await server.handle_request(req)
231+
result = json.loads(resp['result']['content'][0]['text'])
232+
assert 'data' in result
233+
print(f'✅ Example datasets: {result[\"metadata\"][\"rows\"]} rows loaded')
234+
235+
print('🎊 All new features working!')
236+
237+
asyncio.run(test())
238+
"
239+
240+
documentation-check:
241+
name: Documentation Check
242+
runs-on: ubuntu-latest
243+
244+
steps:
245+
- uses: actions/checkout@v4
246+
247+
- name: Check README mentions new features
248+
run: |
249+
grep -q "39 statistical tools" README.md || (echo "❌ README doesn't mention 39 tools" && exit 1)
250+
grep -q "Natural Language" README.md || (echo "❌ README doesn't mention natural language features" && exit 1)
251+
grep -q "Error Recovery" README.md || (echo "❌ README doesn't mention error recovery" && exit 1)
252+
echo "✅ Documentation check passed"
253+
254+
- name: Check version consistency
255+
run: |
256+
grep -q "Version 0.3.5" README.md || (echo "❌ README version not updated" && exit 1)
257+
grep -q "version.*0.3.5" pyproject.toml || (echo "❌ pyproject.toml version not updated" && exit 1)
258+
echo "✅ Version consistency check passed"

0 commit comments

Comments
 (0)