My teammates copy and pasted this code into an app for our project. lass AutoLogout: def process_request(self, request): if not request.user.is_authenticated() : #Can't log out if not logged in return
try: if datetime.now() - request.session['last_touch'] > timedelta( 0, settings.AUTO_LOGOUT_DELAY * 60, 0): auth.logout(request) del request.session['last_touch'] return except KeyError: pass request.session['last_touch'] = datetime.now() I'm trying to write a test to make sure this works. So far I've tried a lot of things, but I don't have much experience with testing. This is what I have, but I don't know how to fix it. class AutoLogoutTest(unittest.TestCase): def setUp(self): self.loggedout = AutoLogout() self.request = Mock() self.client = Client() self.user = User.objects.create_user(username='testuser', password='pass') self.client.login(username='testuser', password='pass') def test_auto_logout(self): session['last_touch'] = timedelta(31*60) response = self.client.get('/logout/', follow=True) self.assertRedirects(response, '/') message = list(response.context['messages']) self.assertEqual(str(message[0]), 'You have successfully logged out.') self.assertNotIn('_auth_user_id', self.client.session) Any help would be appreciated. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9b85e5e7-fe00-4b46-977b-d1217d3abb35%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.