Skip to main content
Glama

Smithsonian Open Access MCP Server

by molanojustin
MIT License
233
2
  • Apple
  • Linux
test_stats_fallback.py2.2 kB
""" Tests for collection statistics fallback handling. """ # TODO: FIX TEST import pytest from unittest.mock import AsyncMock from smithsonian_mcp.api_client import SmithsonianAPIClient from smithsonian_mcp.models import SearchResult, SmithsonianUnit, APIError pytest.importorskip("pytest_asyncio") @pytest.mark.asyncio async def test_get_stats_context_handles_stats_endpoint_failure(monkeypatch): """Ensure stats context handles fallback data with missing metrics.""" client = SmithsonianAPIClient(api_key="test-key") stats_failure = AsyncMock( side_effect=APIError( error="http_error", message="stats endpoint unavailable", status_code=500, details=None, ) ) monkeypatch.setattr(client, "_make_request", stats_failure) fallback_search_result = SearchResult( objects=[], total_count=120, returned_count=0, offset=0, has_more=False, next_offset=None, ) monkeypatch.setattr( client, "search_collections", AsyncMock(return_value=fallback_search_result), ) fallback_units = [ SmithsonianUnit(code="NMAH", name="National Museum of American History", description="", website=None, location=""), SmithsonianUnit(code="NMNH", name="National Museum of Natural History", description="", website=None, location=""), ] monkeypatch.setattr(client, "get_units", AsyncMock(return_value=fallback_units)) monkeypatch.setattr( "smithsonian_mcp.resources.get_api_client", AsyncMock(return_value=client), ) from smithsonian_mcp import resources as resources_module result = await resources_module.get_stats_context.fn() assert "Total Objects: 120" in result assert "Digitized Objects: 0" in result assert "CC0 Licensed Objects: 120" in result assert "Objects with Images (est.): 0" in result assert " NMAH: 120 total, 0 with images (est.)" in result assert " NMNH: 120 total, 0 with images (est.)" in result stats_failure.assert_awaited_once() assert client.search_collections.call_count == 9 client.get_units.assert_awaited_once()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/molanojustin/smithsonian-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server