Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- django - get user logged into test client
- def test_author_set_once(self):
- self.client.login(username='Adam', password='password')
- #create an object and test the author is adam
- self.client.login(username='Barry', password='password')
- #modify the first object and test that the author has not changed
- self.assertEqual(object.author, self.client.user)
- self.client.login(username='Adam', password='password')
- self.user = User.objects.get(username='Adam')
- #create an object
- self.assertEqual(object.author, self.user)
- response.request.user
Add Comment
Please, Sign In to add comment