src/cm/tests/test_notifications.py
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 590 e103299bccc0
permissions -rw-r--r--
add link to "privacy policy" in the header test
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):
590
e103299bccc0 make django tests working again
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
    10
    fixtures = ['initial_data', 'roles_generic','test_content']
0
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
68
db564b6ad6b5 fix test notification
raph
parents: 27
diff changeset
    21
        response = c.post('/followup/', {'notif_id': u'workspace_notify_check', 
278
3d25afbd78ff fix unit tests
raph
parents: 68
diff changeset
    22
                                         'workspace_notify_check': u'true',
68
db564b6ad6b5 fix test notification
raph
parents: 27
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
68
db564b6ad6b5 fix test notification
raph
parents: 27
diff changeset
    28
        response = c.post('/followup/', {'notif_id': u'own_notify_check', 
db564b6ad6b5 fix test notification
raph
parents: 27
diff changeset
    29
                                         'own_notify_check': u'true',
db564b6ad6b5 fix test notification
raph
parents: 27
diff changeset
    30
                                        })
27
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',
68
db564b6ad6b5 fix test notification
raph
parents: 27
diff changeset
    42
                            'version_key' : 'textversion_key_1',
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    43
                            'start_offset' : 16,
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    44
                            'start_wrapper' : 0,
27
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    45
                            'title' : 'sdf', 
29b90002451c fix test notifications
raph
parents: 0
diff changeset
    46
                            'tags': '',   
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    47
                            })
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    48
        self.assertEquals(len(mail.outbox), 1)        
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    49