Files
Orchestrator/bahn/teamlandkarte-mcp/.github/prompts/write-tests.prompt.md
T
ankn a5f8fb49ab Migrate all repos into monorepo context folders
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.
2026-06-30 20:39:52 +02:00

49 lines
1.6 KiB
Markdown

---
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_<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
```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