def test_valid_POST_input_authenticates_user(self):
handler = MagicMock()
user_logged_in.connect(handler)
user = self.create_valid_user()
self.client.post(reverse('login'),
data={'username': 'hans',
'password': 'ihaveapassword'})
self.assertEqual(handler.call_count, 1)
self.assertEqual(self.client.session[SESSION_KEY], str(user.pk))
评论列表
文章目录