Which HTTP request method is typically used to update an existing resource on a server?
Think about which method replaces the entire resource with new data.
The PUT method is used to update or replace an existing resource entirely. POST is usually for creating new resources, GET retrieves data, and DELETE removes resources.
What is the meaning of the HTTP status code 404?
It is a common error when a webpage is missing.
404 means the requested resource could not be found on the server. 201 means created, 500 means internal server error, and 401 means unauthorized.
Which assertion correctly checks that an HTTP response status code is 200 in a test?
response = client.get('/api/data')Check the attribute name and use the correct comparison operator.
The correct attribute is 'status_code' and the comparison operator is '=='. Option C uses a string which may not be standard, C uses a wrong attribute, and D uses assignment '=' instead of comparison '=='.
A test sends a POST request to an endpoint but receives a 405 Method Not Allowed error. What is the most likely cause?
405 means the method is not allowed on that URL.
405 status code means the HTTP method used is not supported by the endpoint. Server down would cause no response or 5xx errors, incorrect URL usually 404, and missing body usually 400 or 422.
In an automated API test suite, which feature of a test framework best helps to verify multiple HTTP status codes efficiently?
Think about reducing repeated code and improving test coverage.
Parameterized tests allow running one test logic multiple times with different inputs and expected outputs, making it efficient to check various status codes. Writing separate tests is repetitive, ignoring status codes misses important checks, and print statements are not automated verification.