Guest User

Untitled

a guest
Sep 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1.     def test_post_login_form_connected(self):
  2.         # Conditions
  3.         user = User.objects.create_user('toto_username', 'toto@example.com', 'toto_password')
  4.        
  5.         # Actions
  6.         data = {
  7.                 'email': 'toto@example.com',
  8.                 'password': 'toto_password',
  9.                 }
  10.         response = self.client.post('/login/', data)
  11.  
  12.        
  13.         # Verify Redirect
  14.         self.assertRedirects(response, '/home/', 302, 200)
  15.  
  16.     # Verify authentication
  17.     # Check if the users id is stored in the session
  18.     # If so that means that we're authenticated
  19.     self.assertEqual(self.client.session['_auth_user_id'], user.pk)
Add Comment
Please, Sign In to add comment