mcp-browser/tests/test_onboarding.py
Claude4Ξlope 27d0f610ba Fix MCP Browser test suite and add Brave Search integration
- Fixed NameError by adding missing Union import in filter.py
- Reorganized all tests into tests/ subdirectory
- Fixed recursive initialization issue in proxy.py
- Added proper test infrastructure with Makefile and setup.py test target
- Created test_config.yaml for test configurations
- Added Brave Search integration test (requires BRAVE_API_KEY)
- Fixed async test fixtures to use @pytest_asyncio.fixture
- Updated tests to handle 3 sparse tools (including onboarding)
- Fixed JSONPath queries to avoid unsupported filter syntax
- Created unit tests that don't require server initialization
- Added test_simple.py for basic functionality tests

All unit tests now pass successfully. Integration tests that require
full server setup are marked as skipped.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 14:11:13 +02:00

92 lines
No EOL
2.5 KiB
Python

#!/usr/bin/env python3
"""
Quick test of the onboarding functionality.
"""
import asyncio
import sys
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent))
from mcp_browser import MCPBrowser
import pytest
@pytest.mark.asyncio
async def test_onboarding():
"""Test onboarding functionality."""
print("Testing MCP Browser Onboarding...\n")
# Use test config
config_path = Path(__file__).parent / "test_config.yaml"
browser = MCPBrowser(config_path=config_path, server_name="builtin-only")
try:
await browser.initialize()
print("✓ Browser initialized\n")
# Test 1: Get onboarding for new identity
print("1. Getting onboarding for 'TestBot':")
response = await browser.call({
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "onboarding",
"arguments": {
"identity": "TestBot"
}
}
})
if "result" in response:
content = response["result"]["content"][0]["text"]
print(content[:200] + "...\n")
# Test 2: Set onboarding
print("2. Setting onboarding instructions:")
response = await browser.call({
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "onboarding",
"arguments": {
"identity": "TestBot",
"instructions": "You are TestBot. Your primary goals:\n- Be helpful\n- Be concise\n- Remember context"
}
}
})
if "result" in response:
print("✓ Instructions set\n")
# Test 3: Retrieve onboarding
print("3. Retrieving onboarding:")
response = await browser.call({
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "onboarding",
"arguments": {
"identity": "TestBot"
}
}
})
if "result" in response:
content = response["result"]["content"][0]["text"]
print(content)
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
finally:
await browser.close()
print("\n✓ Test complete")
if __name__ == "__main__":
asyncio.run(test_onboarding())