ComeçarComece de graça

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

Ver curso

Instruções do exercício

  • Start Claude Code with claude.
  • Reference @db_routes.py and ask Claude to write a pytest integration test for the endpoint.
  • Once the test looks good, ask Claude to run it.
  • When done, type /exit to 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