Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
1.6 KiB
1.6 KiB
description
| 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 pytestoruv run pytest -v
Conventions
- Use
@pytest.mark.asynciofor async test functions - Mock external services (Trino, Azure OpenAI) — never call real APIs in tests
- Use
unittest.mock.AsyncMockfor async mocks - Test file naming:
tests/test_<module>.py - Test function naming:
test_<what_is_being_tested>
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
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
- Run:
uv run pytest— all tests must pass - Run:
uv run ruff check tests/— no lint errors - Run:
uv run mypy src/— type check still passes