Complete the code to define a contract test that checks the provider's response status.
def test_provider_response(): response = provider.get_data() assert response.status_code == [1]
The HTTP status code 200 means the request was successful, which is expected in a contract test for a valid response.
Complete the code to verify the provider returns the expected JSON key in the contract test.
def test_provider_data_keys(): data = provider.get_data().json() assert '[1]' in data
The contract expects the provider to return a JSON with the key userId, which identifies the user data.
Fix the error in the assertion to correctly check the provider's response content type.
def test_content_type(): response = provider.get_data() assert response.headers['Content-Type'] == [1]
The contract requires the provider to return JSON data, so the content type must be application/json.
Fill both blanks to create a contract test that checks the provider's response time and status code.
def test_response_time_and_status(): response = provider.get_data() assert response.elapsed.total_seconds() [1] 1.0 assert response.status_code [2] 200
The test checks that the response time is less than 1 second and the status code equals 200, ensuring performance and correctness.
Fill all three blanks to write a contract test that verifies the provider's JSON response structure.
def test_json_structure(): data = provider.get_data().json() assert isinstance(data, [1]) assert '[2]' in data assert isinstance(data['[2]'], [3])
The response should be a dictionary containing a key 'user', which itself is a dictionary representing user details.