src/cm/tests/test_notifications.py
author raph
Tue, 08 Dec 2009 16:33:11 +0100
changeset 27 29b90002451c
parent 0 40c8f766c9b8
child 68 db564b6ad6b5
permissions -rw-r--r--
fix test notifications
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
from django.core import mail
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
from django.test import TestCase
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
from django.test.client import Client
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     4
from django.core import management
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     5
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     6
from cm.models import *
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     7
from cm.models_utils import *
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     8
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     9
class NotificationTest(TestCase):
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    10
    fixtures = ['roles_generic','test_content']
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    11
    
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    12
    def setUp(self):
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    13
        pass
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    14
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    15
    def test_simple_notification(self):
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    16
        c = Client()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    17
        c.login(username='user1', password='test')
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    18
        self.assertEquals(len(Notification.objects.all()), 0)
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    19
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    20
        # subscribe to workspace notifications
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    21
        response = c.post('/notifications/', {'notif_id': u'workspace_notify_check', 
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    22
                                              'workspace_notify_check': u'workspace_notify_check',
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    23
                                              })
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    24
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    25
        self.assertEquals(len(Notification.objects.all()), 1)
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    26
        
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    27
        # subscribe to own notifications
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    28
        response = c.post('/notifications/', {'notif_id': u'own_notify_check', 
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    29
                                              'own_notify_check': u'true',
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    30
                                              })
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    31
        
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    32
        self.assertEquals(len(Notification.objects.all()), 2)
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    33
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    34
        self.assertEquals(len(mail.outbox), 0)        
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    35
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    36
        c.post('/client/', {'content' : 'sdf',
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    37
                            'end_offset' : 19,
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    38
                            'end_wrapper' : 0,
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    39
                            'format' : 'markdown',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    40
                            'fun' : 'addComment',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    41
                            'key' : 'text_key_1',
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    42
                            'start_offset' : 16,
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    43
                            'start_wrapper' : 0,
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    44
                            'title' : 'sdf', 
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    45
                            'tags': '',   
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    46
                            })
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    47
        self.assertEquals(len(mail.outbox), 1)        
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    48