src/cm/tests/test_notifications.py
changeset 27 29b90002451c
parent 0 40c8f766c9b8
child 68 db564b6ad6b5
equal deleted inserted replaced
26:cef8c0caee3a 27:29b90002451c
     7 from cm.models_utils import *
     7 from cm.models_utils import *
     8 
     8 
     9 class NotificationTest(TestCase):
     9 class NotificationTest(TestCase):
    10     fixtures = ['roles_generic','test_content']
    10     fixtures = ['roles_generic','test_content']
    11     
    11     
    12     def test_global_notification(self):
    12     def setUp(self):
       
    13         pass
       
    14 
       
    15     def test_simple_notification(self):
    13         c = Client()
    16         c = Client()
    14         c.login(username='user1', password='test')
    17         c.login(username='user1', password='test')
    15         print Notification.objects.all()
    18         self.assertEquals(len(Notification.objects.all()), 0)
    16 
    19 
    17         c.post('/notifications/', {'notify_check': u'true'})
    20         # subscribe to workspace notifications
       
    21         response = c.post('/notifications/', {'notif_id': u'workspace_notify_check', 
       
    22                                               'workspace_notify_check': u'workspace_notify_check',
       
    23                                               })
    18 
    24 
    19         # ? error ? django tests system bug?
    25         self.assertEquals(len(Notification.objects.all()), 1)
       
    26         
       
    27         # subscribe to own notifications
       
    28         response = c.post('/notifications/', {'notif_id': u'own_notify_check', 
       
    29                                               'own_notify_check': u'true',
       
    30                                               })
       
    31         
       
    32         self.assertEquals(len(Notification.objects.all()), 2)
       
    33 
       
    34         self.assertEquals(len(mail.outbox), 0)        
       
    35 
    20         c.post('/client/', {'content' : 'sdf',
    36         c.post('/client/', {'content' : 'sdf',
    21                             'end_offset' : 11,
    37                             'end_offset' : 19,
    22                             'end_wrapper' : 0,
    38                             'end_wrapper' : 0,
    23                             'format' : 'markdown',
    39                             'format' : 'markdown',
    24                             'fun' : 'addComment',
    40                             'fun' : 'addComment',
    25                             'key' : 'text_key_1',
    41                             'key' : 'text_key_1',
    26                             'start_offset' : 8,
    42                             'start_offset' : 16,
    27                             'start_wrapper' : 0,
    43                             'start_wrapper' : 0,
    28                             'title' : 'sdf',
    44                             'title' : 'sdf', 
       
    45                             'tags': '',   
    29                             })
    46                             })
    30         self.assertEquals(len(mail.outbox), 1)        
    47         self.assertEquals(len(mail.outbox), 1)        
    31         
    48