mirror of
https://github.com/wso2/fhir-mcp-server.git
synced 2025-11-14 22:18:14 +03:00
* Initial plan * Add comprehensive tests for utils and OAuth types modules Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Complete comprehensive test suite for FHIR MCP server with 123 tests Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Fix test dependencies and improve setup documentation - Add test dependencies (pytest, pytest-asyncio, pytest-cov) to pyproject.toml as optional dependencies - Create requirements-dev.txt for easier development setup - Enhance run_tests.py with dependency checking and clear error messages - Update README with comprehensive testing and development setup instructions - Verified that all 123 tests pass successfully with proper dependencies Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Fix test failures and improve coverage Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Fix integration test to use mocked URLs instead of external services Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Fix test failures: add proper async/await to standalone tests and fix server provider test interface Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Fix test failures: repair broken test_utils.py and ensure tests can run with basic dependencies Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com> * Fix tests - made them run on headless mode - made all tests pass * Fix review comments --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nirmal070125 <413016+nirmal070125@users.noreply.github.com>
88 lines
2.5 KiB
Python
Executable File
88 lines
2.5 KiB
Python
Executable File
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com/) All Rights Reserved.
|
|
|
|
# WSO2 LLC. licenses this file to you under the Apache License,
|
|
# Version 2.0 (the "License"); you may not use this file except
|
|
# in compliance with the License.
|
|
# You may obtain postgres_pgvector copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
"""
|
|
Test runner script for the FHIR MCP Server.
|
|
|
|
This script provides an easy way to run all tests with proper configuration.
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
|
|
def check_dependencies():
|
|
"""Check if test dependencies are installed."""
|
|
try:
|
|
import pytest
|
|
import pytest_asyncio
|
|
import pytest_cov
|
|
return True
|
|
except ImportError as e:
|
|
print("❌ Test dependencies not found!")
|
|
print(f"Missing: {e.name}")
|
|
print("\nTo install test dependencies, run one of:")
|
|
print(" pip install -e .[test]")
|
|
print(" pip install -r requirements-dev.txt")
|
|
print(" uv sync --dev")
|
|
return False
|
|
|
|
|
|
def run_tests():
|
|
"""Run all tests with proper Python path and configuration."""
|
|
|
|
# Check dependencies first
|
|
if not check_dependencies():
|
|
return 1
|
|
|
|
# Set up the environment
|
|
project_root = os.path.dirname(os.path.abspath(__file__))
|
|
src_path = os.path.join(project_root, 'src')
|
|
|
|
# Set PYTHONPATH
|
|
env = os.environ.copy()
|
|
env['PYTHONPATH'] = src_path
|
|
|
|
# Run pytest with coverage
|
|
cmd = [
|
|
sys.executable, '-m', 'pytest',
|
|
'tests/',
|
|
'-v',
|
|
'--cov=src/fhir_mcp_server',
|
|
'--cov-report=term-missing',
|
|
'--cov-report=html:htmlcov'
|
|
]
|
|
|
|
print(f"Running tests with command: {' '.join(cmd)}")
|
|
print(f"PYTHONPATH: {src_path}")
|
|
print("-" * 50)
|
|
|
|
result = subprocess.run(cmd, env=env, cwd=project_root)
|
|
return result.returncode
|
|
|
|
|
|
if __name__ == '__main__':
|
|
exit_code = run_tests()
|
|
if exit_code == 0:
|
|
print("\n" + "=" * 50)
|
|
print("✅ All tests passed successfully!")
|
|
print("📊 Coverage report generated in htmlcov/index.html")
|
|
else:
|
|
print("\n" + "=" * 50)
|
|
print("❌ Some tests failed. Please check the output above.")
|
|
|
|
sys.exit(exit_code) |