0
0
Testing Fundamentalstesting~10 mins

Request methods and status codes in Testing Fundamentals - Interactive Code Practice

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

Complete the code to check if the HTTP request method is GET.

Testing Fundamentals
if request.method == '[1]':
    print("This is a GET request")
Drag options to blanks, or click blank then click option'
APOST
BGET
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'get' instead of uppercase 'GET'.
Confusing GET with POST method.
2fill in blank
medium

Complete the code to assert the HTTP response status code is 404 (Not Found).

Testing Fundamentals
assert response.status_code == [1]
Drag options to blanks, or click blank then click option'
A200
B302
C404
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using 200 which means OK instead of 404.
Using string '404' instead of integer 404.
3fill in blank
hard

Fix the error in the code that checks if the request method is POST.

Testing Fundamentals
if request.method == '[1]':
    process_post_request()
Drag options to blanks, or click blank then click option'
APOST
Bpost
CPut
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'post' which will not match.
Confusing POST with PUT or GET.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps status codes to their meaning for codes greater than 399.

Testing Fundamentals
error_codes = {code: messages[code] for code in codes if code [1] 399 and code [2] 600}
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= 399 includes non-error codes.
Using >= 600 includes codes outside standard HTTP status codes.
5fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps uppercase HTTP methods to their success status codes greater or equal to 200.

Testing Fundamentals
success_status = {method: code for method, code in method_codes.items() if code [1] 200 and method[2].isupper()}
Drag options to blanks, or click blank then click option'
A.lower()
B>=
D.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using .lower() which would convert method names incorrectly.
Using empty string for blank 2 which causes syntax error.