#!/usr/bin/env python3
"""
Unit tests for RMCP server core functionality (Python-only).
Tests that don't require R execution.
"""
import sys
from pathlib import Path
import pytest
def test_dependencies():
"""Test that required Python dependencies are available."""
print("π Testing Dependencies")
print("-" * 40)
try:
import click
print("β
click available")
except ImportError:
print("β click missing - install with: pip install click")
assert False, "click missing"
try:
import jsonschema
print("β
jsonschema available")
except ImportError:
print("β jsonschema missing - install with: pip install jsonschema")
assert False, "jsonschema missing"
def test_basic_server_import():
"""Test that the server can be imported without errors."""
print("\nπ Testing Server Import")
print("-" * 40)
try:
# Try to import core components
from rmcp.core.context import Context, LifespanState
print("β
Core context imported")
from rmcp.core.server import create_server
print("β
Server creation imported")
# Try to create basic server
server = create_server()
print("β
Server created successfully")
except ImportError as e:
print(f"β Import error: {e}")
assert False, f"Import error: {e}"
except Exception as e:
print(f"β Server creation failed: {e}")
assert False, f"Server creation failed: {e}"
# R-dependent tests and CLI tests moved to tests/integration/test_server_integration.py
def main():
"""Run Python-only server tests."""
print("π§ͺ RMCP Server Python-Only Tests")
print("=" * 50)
tests = [
("Dependencies", test_dependencies),
("Server Import", test_basic_server_import),
]
passed = 0
total = len(tests)
for name, test_func in tests:
try:
if test_func():
passed += 1
else:
print(f"\nβ {name} test failed")
except Exception as e:
print(f"\nβ {name} test error: {e}")
print("\n" + "=" * 50)
print(f"π Results: {passed}/{total} tests passed")
if passed == total:
print("β
RMCP Python components work!")
return True
else:
print("β RMCP Python components have issues")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)