Bird
0
0

Identify the error in this test snippet:

medium📝 Debug Q6 of 15
Rest API - API Testing and Monitoring
Identify the error in this test snippet:
response = client.get('/products')
assert response.status == 200
assert 'items' in response.json()
AWrong HTTP method used
BMissing parentheses after json
CNo error, test is correct
DIncorrect attribute 'status' instead of 'status_code'
Step-by-Step Solution
Solution:
  1. Step 1: Check status code attribute usage

    Correct attribute is 'status_code', not 'status'.
  2. Step 2: Verify JSON access and HTTP method

    json() is called correctly, and GET is appropriate for '/products'.
  3. Final Answer:

    Incorrect attribute 'status' instead of 'status_code' -> Option D
  4. Quick Check:

    Status code attribute must be 'status_code' [OK]
Quick Trick: Use response.status_code, not response.status [OK]
Common Mistakes:
MISTAKES
  • Using 'status' instead of 'status_code'
  • Forgetting to call json() as a function
  • Confusing HTTP methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes