Skip to main content
Glama

MaverickMCP

by wshobson
MIT License
165
  • Apple
test_template.py5.43 kB
""" Template for creating new test files. Copy this file and modify it to create new tests quickly. """ from datetime import UTC, datetime from unittest.mock import Mock, patch import pytest # Import what you're testing # from maverick_mcp.your_module import YourClass, your_function class TestYourClass: """Test suite for YourClass.""" @pytest.fixture def mock_dependencies(self): """Set up common mocks for tests.""" with patch("maverick_mcp.your_module.external_dependency") as mock_dep: mock_dep.return_value = Mock() yield { "dependency": mock_dep, } @pytest.fixture def sample_data(self): """Provide sample test data.""" return { "id": 1, "name": "Test Item", "value": 42.0, "created_at": datetime.now(UTC), } def test_initialization(self): """Test class initialization.""" # obj = YourClass(param1="value1", param2=42) # assert obj.param1 == "value1" # assert obj.param2 == 42 pass def test_method_success(self, mock_dependencies, sample_data): """Test successful method execution.""" # Arrange # obj = YourClass() # mock_dependencies["dependency"].some_method.return_value = "expected" # Act # result = obj.your_method(sample_data) # Assert # assert result == "expected" # mock_dependencies["dependency"].some_method.assert_called_once_with(sample_data) pass def test_method_validation_error(self): """Test method with invalid input.""" # obj = YourClass() # with pytest.raises(ValueError, match="Invalid input"): # obj.your_method(None) pass @pytest.mark.asyncio async def test_async_method(self, mock_dependencies): """Test asynchronous method.""" # Arrange # obj = YourClass() # mock_dependencies["dependency"].async_method = AsyncMock(return_value="async_result") # Act # result = await obj.async_method() # Assert # assert result == "async_result" pass class TestYourFunction: """Test suite for standalone functions.""" def test_function_basic(self): """Test basic function behavior.""" # result = your_function("input") # assert result == "expected_output" pass def test_function_edge_cases(self): """Test edge cases.""" # Test empty input # assert your_function("") == "" # Test None input # with pytest.raises(TypeError): # your_function(None) # Test large input # large_input = "x" * 10000 # assert len(your_function(large_input)) <= 10000 pass @pytest.mark.parametrize( "input_value,expected", [ ("test1", "result1"), ("test2", "result2"), ("", ""), ("special!@#", "special"), ], ) def test_function_parametrized(self, input_value, expected): """Test function with multiple inputs.""" # result = your_function(input_value) # assert result == expected pass class TestIntegration: """Integration tests (marked for optional execution).""" @pytest.mark.integration def test_database_integration(self, db_session): """Test database operations.""" # This test requires a real database connection # from maverick_mcp.your_module import create_item, get_item # # Create # item = create_item(db_session, name="Test", value=42) # assert item.id is not None # # Read # retrieved = get_item(db_session, item.id) # assert retrieved.name == "Test" # assert retrieved.value == 42 pass @pytest.mark.integration @pytest.mark.asyncio async def test_external_api_integration(self): """Test external API calls.""" # This test makes real API calls # from maverick_mcp.your_module import fetch_external_data # result = await fetch_external_data("AAPL") # assert result is not None # assert "price" in result pass # Fixtures that can be reused across tests @pytest.fixture def mock_redis(): """Mock Redis client.""" with patch("maverick_mcp.data.cache.get_redis_client") as mock: redis_mock = Mock() redis_mock.get.return_value = None redis_mock.set.return_value = True mock.return_value = redis_mock yield redis_mock @pytest.fixture def mock_settings(): """Mock settings for testing.""" with patch("maverick_mcp.config.settings.settings") as mock: mock.auth.enabled = False mock.api.debug = True yield mock # Performance tests (optional) @pytest.mark.slow class TestPerformance: """Performance tests (excluded by default).""" def test_large_dataset_processing(self): """Test processing of large datasets.""" # import time # from maverick_mcp.your_module import process_data # large_data = list(range(1_000_000)) # start = time.time() # result = process_data(large_data) # duration = time.time() - start # assert len(result) == 1_000_000 # assert duration < 1.0 # Should complete in under 1 second pass

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/wshobson/maverick-mcp'

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