src/cm/tests/test_notifications.py
author Simon Descarpentries <sid@sopinspace.com>
Mon, 21 Oct 2013 16:37:07 +0200
changeset 553 bf26fb47a14c
parent 278 3d25afbd78ff
child 590 e103299bccc0
permissions -rw-r--r--
To allow scrolling in Safari mobile, we set the content of text_view_comments frame in a jQuery UI layout. So the automated scrolling operations in c_sync.js must be adjustable to the right part to scroll. Also, if a comment have to be shown outside of the current viewport, we scroll the correct part to that viewport and then set the comment top Y offset to juste what it needs to avoid the "Add comment" button after scrolling operation. If not in Safari mobile, we add an offset here to avoid comment to display under the "Add comment" button.
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
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