liveBook · Manning

Mock data

As explained in Build Python Web Apps with Streamlit

Mock data is fabricated data designed to imitate the structure and content of data supplied by a real dependency.

Mock data is fabricated data that imitates a real dependency’s structure without requiring live calls. In backend tests, dictionaries and lists can mirror the fields and response shape returned by the TMDB API. section 11.3.2

A small mock dataset can represent several layers of an API response:

  • MOCK_MOVIE_1 and MOCK_MOVIE_2 represent individual movie records. section 11.3.2
  • MOCK_MOVIES represents the API’s results list. section 11.3.2
  • MOCK_RESULTS represents the backend’s ID-keyed result mapping. section 11.3.2
Listing 11.4 Mock data in mock_data.py
MOCK_MOVIE_1 = {
  "id": "123",
  "title": "Test Movie 1",
  "overview": "This is a test movie",
  "vote_average": 8.5,
  "release_date": "2023-01-01",
  "poster_path": "/test_poster1.jpg"
}

MOCK_MOVIE_2 = {
  "id": "456",
  "title": "Test Movie 2",
  "overview": "Another test movie",
  "vote_average": 7.0,
  "release_date": "2022-05-15",
  "poster_path": "/test_poster2.jpg"
}

MOCK_MOVIES = [MOCK_MOVIE_1, MOCK_MOVIE_2]
MOCK_RESULTS = {"123": MOCK_MOVIE_1, "456": MOCK_MOVIE_2}

Inspect the complete mock dataset, including two movie dictionaries, the results list, and the ID-keyed mapping. section 11.3.2

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines nested response shapes and uses them in assertions, but does not develop broader test design beyond the shown cases.
Examples
Uses two movie dictionaries, a results list, an ID-keyed mapping, and an empty-results response.
What it assumes
Assumes Python dictionaries, lists, a Backend class, and an API response format; explains the required mock shapes.
What you can do after
Apply mock data in pytest tests to verify backend search behavior without making real API calls.
How it connects
Links mock data with unit testing, pytest fixtures, HTTP mocking, and API response schemas.

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.