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
