chore: upgrade all Python packages and fix linting issues
- Update all dependencies to latest versions (fastmcp, httpx, packaging, etc.) - Downgrade click from yanked 8.2.2 to stable 8.1.7 - Fix code formatting and linting issues with ruff - Most tests passing (2 test failures in dependency resolver need investigation)
This commit is contained in:
parent
503ea589f1
commit
8b43927493
34 changed files with 2276 additions and 1593 deletions
|
|
@ -159,7 +159,7 @@ class TestDownloadStats:
|
|||
async def test_get_top_packages_by_downloads_fallback(self):
|
||||
"""Test top packages retrieval when PyPI API fails (fallback mode)."""
|
||||
from pypi_query_mcp.core.exceptions import PyPIServerError
|
||||
|
||||
|
||||
with patch(
|
||||
"pypi_query_mcp.tools.download_stats.PyPIStatsClient"
|
||||
) as mock_stats_client:
|
||||
|
|
@ -180,7 +180,7 @@ class TestDownloadStats:
|
|||
assert all("category" in pkg for pkg in result["top_packages"])
|
||||
assert all("description" in pkg for pkg in result["top_packages"])
|
||||
assert "curated" in result["data_source"]
|
||||
|
||||
|
||||
# Check that all packages have estimated downloads
|
||||
assert all(pkg.get("estimated", False) for pkg in result["top_packages"])
|
||||
|
||||
|
|
@ -188,47 +188,56 @@ class TestDownloadStats:
|
|||
async def test_get_top_packages_github_enhancement(self):
|
||||
"""Test GitHub enhancement functionality."""
|
||||
from pypi_query_mcp.core.exceptions import PyPIServerError
|
||||
|
||||
|
||||
mock_github_stats = {
|
||||
"stars": 50000,
|
||||
"forks": 5000,
|
||||
"updated_at": "2024-01-01T00:00:00Z",
|
||||
"language": "Python",
|
||||
"topics": ["http", "requests"]
|
||||
"topics": ["http", "requests"],
|
||||
}
|
||||
|
||||
|
||||
with (
|
||||
patch("pypi_query_mcp.tools.download_stats.PyPIStatsClient") as mock_stats_client,
|
||||
patch("pypi_query_mcp.tools.download_stats.GitHubAPIClient") as mock_github_client
|
||||
patch(
|
||||
"pypi_query_mcp.tools.download_stats.PyPIStatsClient"
|
||||
) as mock_stats_client,
|
||||
patch(
|
||||
"pypi_query_mcp.tools.download_stats.GitHubAPIClient"
|
||||
) as mock_github_client,
|
||||
):
|
||||
# Mock PyPI failure
|
||||
mock_stats_instance = AsyncMock()
|
||||
mock_stats_instance.get_recent_downloads.side_effect = PyPIServerError(502)
|
||||
mock_stats_client.return_value.__aenter__.return_value = mock_stats_instance
|
||||
|
||||
# Mock GitHub success
|
||||
|
||||
# Mock GitHub success
|
||||
mock_github_instance = AsyncMock()
|
||||
mock_github_instance.get_multiple_repo_stats.return_value = {
|
||||
"psf/requests": mock_github_stats
|
||||
}
|
||||
mock_github_client.return_value.__aenter__.return_value = mock_github_instance
|
||||
mock_github_client.return_value.__aenter__.return_value = (
|
||||
mock_github_instance
|
||||
)
|
||||
|
||||
result = await get_top_packages_by_downloads("month", 10)
|
||||
|
||||
|
||||
# Find requests package (should be enhanced with GitHub data)
|
||||
requests_pkg = next((pkg for pkg in result["top_packages"] if pkg["package"] == "requests"), None)
|
||||
|
||||
requests_pkg = next(
|
||||
(pkg for pkg in result["top_packages"] if pkg["package"] == "requests"),
|
||||
None,
|
||||
)
|
||||
|
||||
if requests_pkg:
|
||||
assert "github_stars" in requests_pkg
|
||||
assert "github_forks" in requests_pkg
|
||||
assert requests_pkg["github_stars"] == 50000
|
||||
assert requests_pkg.get("github_enhanced", False) == True
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_top_packages_different_periods(self):
|
||||
"""Test top packages with different time periods."""
|
||||
from pypi_query_mcp.core.exceptions import PyPIServerError
|
||||
|
||||
|
||||
with patch(
|
||||
"pypi_query_mcp.tools.download_stats.PyPIStatsClient"
|
||||
) as mock_stats_client:
|
||||
|
|
@ -238,16 +247,20 @@ class TestDownloadStats:
|
|||
|
||||
for period in ["day", "week", "month"]:
|
||||
result = await get_top_packages_by_downloads(period, 3)
|
||||
|
||||
|
||||
assert result["period"] == period
|
||||
assert len(result["top_packages"]) == 3
|
||||
|
||||
|
||||
# Check that downloads are scaled appropriately for the period
|
||||
# Day should have much smaller numbers than month
|
||||
if period == "day":
|
||||
assert all(pkg["downloads"] < 50_000_000 for pkg in result["top_packages"])
|
||||
assert all(
|
||||
pkg["downloads"] < 50_000_000 for pkg in result["top_packages"]
|
||||
)
|
||||
elif period == "month":
|
||||
assert any(pkg["downloads"] > 100_000_000 for pkg in result["top_packages"])
|
||||
assert any(
|
||||
pkg["downloads"] > 100_000_000 for pkg in result["top_packages"]
|
||||
)
|
||||
|
||||
def test_analyze_download_stats(self):
|
||||
"""Test download statistics analysis."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue