--- description: Write tests for Teamlandkarte MCP server components following project conventions. --- $ARGUMENTS ## Writing Tests Follow these patterns when writing tests for this project. ### Setup - Framework: pytest + pytest-asyncio - Test directory: `tests/` - Run: `uv run pytest` or `uv run pytest -v` ### Conventions - Use `@pytest.mark.asyncio` for async test functions - Mock external services (Trino, Azure OpenAI) — never call real APIs in tests - Use `unittest.mock.AsyncMock` for async mocks - Test file naming: `tests/test_.py` - Test function naming: `test_` ### Key Test Areas - **Confirmation gating**: Verify matching refuses to run without confirmation - **Search robustness**: Empty results, invalid inputs, expired sessions - **Filtering/pagination**: Category browsing, filter application, page boundaries - **Cache behavior**: TTL expiry, cache hits/misses - **Schema validation**: Invalid parameters, missing required fields - **Edge cases**: Empty competence lists, very long descriptions, special characters ### Mocking Patterns ```python from unittest.mock import AsyncMock, patch, MagicMock @pytest.mark.asyncio async def test_something(): mock_client = AsyncMock() mock_client.execute_query.return_value = [{"id": "1", "title": "Test"}] with patch("src.teamlandkarte_mcp.database.db_client.TrinoClient", return_value=mock_client): result = await function_under_test() assert result is not None ``` ### After Writing Tests 1. Run: `uv run pytest` — all tests must pass 2. Run: `uv run ruff check tests/` — no lint errors 3. Run: `uv run mypy src/` — type check still passes