comparison wiki/tests/test_receivers.py @ 939:3782fa705821

Add test for wiki signal handlers.
author Brian Neal <bgneal@gmail.com>
date Wed, 29 Apr 2015 20:29:47 -0500
parents
children
comparison
equal deleted inserted replaced
938:9f9e50df5b83 939:3782fa705821
1 """Tests for the wiki app's signal handlers."""
2 import logging
3
4 from django.contrib.auth.models import User
5 from django.test import TestCase
6
7 from testfixtures import log_capture
8
9
10 class ReceiverTestCase(TestCase):
11
12 def setUp(self):
13 self.user = User.objects.create_user('user', 'user@example.com', 'pw')
14
15 # Temporarily enable logging
16 self.old_disable = logging.getLogger().manager.disable
17 logging.disable(logging.NOTSET)
18
19 def tearDown(self):
20 logging.disable(self.old_disable)
21
22 @log_capture('wiki.receivers')
23 def test_signal_handlers(self, lc):
24 # We don't have access to the dummy request that the test client creates
25 # when logging in, so we can't really check to see if we added
26 # attributes to the request object. But that code is pretty simple, so
27 # lets just test that we logged something so we know our signal handlers
28 # are hooked up and running.
29 self.client.login(username='user', password='pw')
30 self.client.logout()
31 lc.check(('wiki.receivers', 'INFO', 'User login: user'),
32 ('wiki.receivers', 'INFO', 'User logout: user'))