Complete the code to import the Django test client.
from django.test import [1]
The Django test client is imported using Client from django.test. It allows simulating user requests in tests.
Complete the code to check if a test response status code is 200 (OK).
self.assertEqual(response.[1], 200)
The response object in Django tests has a status_code attribute that holds the HTTP status code returned.
Fix the error in the test method to correctly check for a redirect status.
self.assertEqual(response.[1], 302)
The correct attribute to check the HTTP status code, including redirects, is status_code.
Fill both blanks to assert the response contains the text 'Welcome' and has status 200.
self.assertContains(response, [1]) self.assertEqual(response.[2], 200)
assertContains checks if the response content includes the given text. The status code is checked with status_code.
Fill all three blanks to check the response is a redirect to '/login/' with status 302.
self.assertEqual(response.[1], 302) self.assertEqual(response.[2], '/login/') self.assertTrue(response.[3])
The status code for redirect is checked with status_code. The redirect target URL is in url. The presence of the 'Location' header is checked with has_header('Location').