bgneal@939: """Tests for the wiki app's signal handlers.""" bgneal@939: import logging bgneal@939: bgneal@939: from django.contrib.auth.models import User bgneal@939: from django.test import TestCase bgneal@939: bgneal@939: from testfixtures import log_capture bgneal@939: bgneal@939: bgneal@939: class ReceiverTestCase(TestCase): bgneal@939: bgneal@939: def setUp(self): bgneal@939: self.user = User.objects.create_user('user', 'user@example.com', 'pw') bgneal@939: bgneal@939: # Temporarily enable logging bgneal@939: self.old_disable = logging.getLogger().manager.disable bgneal@939: logging.disable(logging.NOTSET) bgneal@939: bgneal@939: def tearDown(self): bgneal@939: logging.disable(self.old_disable) bgneal@939: bgneal@939: @log_capture('wiki.receivers') bgneal@939: def test_signal_handlers(self, lc): bgneal@939: # We don't have access to the dummy request that the test client creates bgneal@939: # when logging in, so we can't really check to see if we added bgneal@939: # attributes to the request object. But that code is pretty simple, so bgneal@939: # lets just test that we logged something so we know our signal handlers bgneal@939: # are hooked up and running. bgneal@939: self.client.login(username='user', password='pw') bgneal@939: self.client.logout() bgneal@939: lc.check(('wiki.receivers', 'INFO', 'User login: user'), bgneal@939: ('wiki.receivers', 'INFO', 'User logout: user'))