Write and Run Integration Tests
The db_routes.py Blueprint from lesson 3.3 is integrated with the Music Analytics API. You can view it here: music-analytics-api-with-db-routed-validated/db_routes.py. It returns albums by artist with Pydantic validation:
class Album(BaseModel):
AlbumId: int
Title: str
class ArtistAlbumsResponse(BaseModel):
artist_id: int
artist_name: str
albums: list[Album]
@db_routes.route("/artists/<int:artist_id>/albums")
def get_artist_albums(artist_id):
# Queries chinook.db, returns 404 if artist not found
...
You're already in music-analytics-api-with-db-routed-validated/; MCP is configured there. Ask Claude to write a pytest integration test, review it, and then run it.
Este exercício faz parte do curso
Software Development with Claude Code
Instruções do exercício
- Start Claude Code with
claude. - Reference
@db_routes.pyand ask Claude to write a pytest integration test for the endpoint. - Once the test looks good, ask Claude to run it.
- When done, type
/exitto exit Claude Code.
Exercício interativo prático
Transforme a teoria em ação com um de nossos exercícios interativos
Começar o exercício