def test_login_signal(self, mock_user_logged_in): client = Client() User.objects.create_user('bouke', '', 'secret') assert client.login(username='******', password='******') assert mock_user_logged_in.called request = mock_user_logged_in.call_args[1]['request'] assert getattr(request, 'user', None) is not None
def test_restore_session(self): store = SessionStore('Python/2.7', '127.0.0.1', None) store['foo'] = 'bar' store.save() client = Client() client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key User.objects.create_user('bouke', '', 'secret') assert client.login(username='******', password='******') self.assertEqual(client.session['foo'], 'bar')
def test_restore_session(self): store = SessionStore("Python/2.7", "127.0.0.1", None) store["foo"] = "bar" store.save() client = Client() client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key User.objects.create_user("bouke", "", "secret") assert client.login(username="******", password="******") self.assertEqual(client.session["foo"], "bar")
def test_login_logout(self): client = Client() User.objects.create_user('bouke', '', 'secret') assert client.login(username='******', password='******') assert settings.SESSION_COOKIE_NAME in client.cookies client.logout() assert settings.SESSION_COOKIE_NAME not in client.cookies # should not raise client.logout()
def test_invalid_login(self): client = Client() self.assertFalse(client.login())