0
0
Testing Fundamentalstesting~10 mins

Why API testing validates backend logic in Testing Fundamentals - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send a GET request to the API endpoint.

Testing Fundamentals
response = requests.[1]('https://api.example.com/data')
Drag options to blanks, or click blank then click option'
Aget
Bpost
Cput
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET to retrieve data.
2fill in blank
medium

Complete the code to check if the API response status code is 200 (OK).

Testing Fundamentals
assert response.[1] == 200
Drag options to blanks, or click blank then click option'
Atext
Bstatus_code
Cjson
Dheaders
Attempts:
3 left
💡 Hint
Common Mistakes
Checking response.text instead of response.status_code.
3fill in blank
hard

Fix the error in the assertion that checks if the 'success' field in JSON response is True.

Testing Fundamentals
assert response.json()[[1]] == True
Drag options to blanks, or click blank then click option'
A'Success'
Bsuccess
C'success'
D'status'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted key causing a NameError.
4fill in blank
hard

Fill both blanks to extract the 'user_id' from JSON response and check if it equals 123.

Testing Fundamentals
user_id = response.json().[1]('user_id')
assert user_id [2] 123
Drag options to blanks, or click blank then click option'
Aget
B==
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment '=' instead of comparison '==' in assertion.
5fill in blank
hard

Fill all three blanks to send a POST request with JSON data and check if response status is 201.

Testing Fundamentals
payload = {'name': 'Alice', 'age': 30}
response = requests.[1]('https://api.example.com/users', json=[2])
assert response.[3] == 201
Drag options to blanks, or click blank then click option'
Apost
Bpayload
Cstatus_code
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST for sending data.
Checking wrong attribute for status code.