feat: Complete PyPI Query MCP Server Implementation (#3)
Merge pull request implementing complete PyPI query MCP server with comprehensive features and CI/CD pipeline.
This commit is contained in:
parent
b1a1a6866d
commit
030b3a2607
33 changed files with 3238 additions and 246 deletions
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Test package for PyPI Query MCP Server."""
|
||||
63
tests/conftest.py
Normal file
63
tests/conftest.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
"""Pytest configuration and fixtures."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_package_data():
|
||||
"""Sample package data for testing."""
|
||||
return {
|
||||
"info": {
|
||||
"name": "test-package",
|
||||
"version": "1.0.0",
|
||||
"summary": "A test package",
|
||||
"description": "This is a test package for testing purposes.",
|
||||
"author": "Test Author",
|
||||
"author_email": "test@example.com",
|
||||
"license": "MIT",
|
||||
"requires_python": ">=3.8",
|
||||
"requires_dist": [
|
||||
"requests>=2.25.0",
|
||||
"click>=8.0.0",
|
||||
"pytest>=6.0.0; extra == 'test'"
|
||||
],
|
||||
"classifiers": [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: Implementation :: CPython"
|
||||
]
|
||||
},
|
||||
"releases": {
|
||||
"1.0.0": [
|
||||
{
|
||||
"filename": "test_package-1.0.0-py3-none-any.whl",
|
||||
"packagetype": "bdist_wheel",
|
||||
"python_version": "py3"
|
||||
},
|
||||
{
|
||||
"filename": "test-package-1.0.0.tar.gz",
|
||||
"packagetype": "sdist",
|
||||
"python_version": "source"
|
||||
}
|
||||
],
|
||||
"0.9.0": [
|
||||
{
|
||||
"filename": "test-package-0.9.0.tar.gz",
|
||||
"packagetype": "sdist",
|
||||
"python_version": "source"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_pypi_response(sample_package_data):
|
||||
"""Mock PyPI API response."""
|
||||
return sample_package_data
|
||||
78
tests/test_basic.py
Normal file
78
tests/test_basic.py
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
"""Basic tests for PyPI Query MCP Server."""
|
||||
|
||||
import pytest
|
||||
|
||||
from pypi_query_mcp import __version__
|
||||
|
||||
|
||||
def test_version():
|
||||
"""Test that version is defined."""
|
||||
assert __version__ == "0.1.0"
|
||||
|
||||
|
||||
def test_import():
|
||||
"""Test that main modules can be imported."""
|
||||
from pypi_query_mcp.core import PyPIClient, VersionCompatibility
|
||||
from pypi_query_mcp.server import app
|
||||
|
||||
assert PyPIClient is not None
|
||||
assert VersionCompatibility is not None
|
||||
assert app is not None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pypi_client_basic():
|
||||
"""Test basic PyPI client functionality."""
|
||||
from pypi_query_mcp.core import PyPIClient
|
||||
|
||||
async with PyPIClient() as client:
|
||||
# Test that client can be created and closed
|
||||
assert client is not None
|
||||
|
||||
# Test cache clearing
|
||||
client.clear_cache()
|
||||
|
||||
|
||||
def test_version_compatibility():
|
||||
"""Test version compatibility utility."""
|
||||
from pypi_query_mcp.core import VersionCompatibility
|
||||
|
||||
compat = VersionCompatibility()
|
||||
|
||||
# Test requires_python parsing
|
||||
spec = compat.parse_requires_python(">=3.8")
|
||||
assert spec is not None
|
||||
|
||||
# Test classifier extraction
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: Implementation :: CPython"
|
||||
]
|
||||
|
||||
versions = compat.extract_python_versions_from_classifiers(classifiers)
|
||||
assert "3.8" in versions
|
||||
assert "3.9" in versions
|
||||
|
||||
implementations = compat.extract_python_implementations(classifiers)
|
||||
assert "CPython" in implementations
|
||||
|
||||
|
||||
def test_mcp_tools_import():
|
||||
"""Test that MCP tools can be imported."""
|
||||
from pypi_query_mcp.tools import (
|
||||
check_python_compatibility,
|
||||
get_compatible_python_versions,
|
||||
query_package_dependencies,
|
||||
query_package_info,
|
||||
query_package_versions,
|
||||
suggest_python_version_for_packages,
|
||||
)
|
||||
|
||||
# Test that all tools are callable
|
||||
assert callable(query_package_info)
|
||||
assert callable(query_package_versions)
|
||||
assert callable(query_package_dependencies)
|
||||
assert callable(check_python_compatibility)
|
||||
assert callable(get_compatible_python_versions)
|
||||
assert callable(suggest_python_version_for_packages)
|
||||
Loading…
Add table
Add a link
Reference in a new issue