bgneal@934: """Tests for the antispam signal handlers.""" bgneal@934: import logging bgneal@934: bgneal@934: from django.contrib.auth.models import User bgneal@934: from django.test import TestCase bgneal@934: bgneal@934: from testfixtures import log_capture bgneal@934: bgneal@934: bgneal@934: class AntispamSignalRcvrTestCase(TestCase): bgneal@934: bgneal@934: def setUp(self): bgneal@934: self.user = User.objects.create_user('steve', 'steve@example.com', 'pwd') bgneal@934: bgneal@934: # Temporarily enable logging bgneal@934: self.old_disable = logging.getLogger().manager.disable bgneal@934: logging.disable(logging.NOTSET) bgneal@934: bgneal@934: def tearDown(self): bgneal@934: logging.disable(self.old_disable) bgneal@934: bgneal@934: @log_capture('auth') bgneal@934: def test_login_logout_callback(self, lc): bgneal@934: self.assertTrue(self.client.login(username='steve', password='pwd')) bgneal@934: self.client.logout() bgneal@934: lc.check(('auth', 'INFO', 'User login signal: steve'), bgneal@934: ('auth', 'INFO', 'User logout signal: steve')) bgneal@934: bgneal@934: @log_capture('auth') bgneal@934: def test_login_failed_callback(self, lc): bgneal@934: self.assertFalse(self.client.login(username='steve', password='xxx')) bgneal@934: lc.check(('auth', 'ERROR', bgneal@934: 'User login failed signal from django.contrib.auth: steve'))