Bắt đầu ngayBắt đầu miễn phí

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.

Bài tập này là một phần của khóa học

Software Development with Claude Code

Xem khóa học

Hướng dẫn bài tập

  • 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.

Bài tập tương tác thực hành

Biến lý thuyết thành hành động với một trong các bài tập tương tác của chúng tôi

Bắt đầu bài tập