def test_login_page_uses_template(self): # Creates a request request = HttpRequest() # Send it to the login_page view response = login_page(request) # Check the content of the file expected_content = render_to_string('login.html') self.assertEqual(expected_content, response.content.decode('utf8'))
def test_login_page_can_login(self): # Create request request = HttpRequest() # Set the method and values for all fields request.method = 'POST' request.POST['username'] = '******' request.POST['password'] = '******' # Send to the view response = login_page(request) # Send context to the template expected_content = render_to_string('login.html', {'login_status': 'Login Failed!'}) # Test if content is as expected self.assertEqual(expected_content, response.content.decode('utf8'))
def test_login_page_can_login_only_password(self): # Create Request request = HttpRequest() # Set the method and the password field request.method = 'POST' request.POST['username'] = '' request.POST['password'] = '******' # Send to the view response = login_page(request) # Send context dict to template expected_content = render_to_string('login.html', {'error_messages': 'Username missing!'}) # Test if content is as expected self.assertEqual(expected_content, response.content.decode('utf8'))
def test_login_page_can_login_only_password(self): # Create Request request = HttpRequest() # Set the method and the password field request.method = 'POST' request.POST['username'] = '' request.POST['password'] = '******' # Send to the view response = login_page(request) # Send context dict to template expected_content = render_to_string( 'login.html', {'error_messages': 'Username missing!'}) # Test if content is as expected self.assertEqual(expected_content, response.content.decode('utf8'))