changeset 2328:495b09143c10

Add a new unit test for _filter_subscriber_list()
author Karol Nowak <grzywacz@sul.uni.lodz.pl>
date Tue, 26 Jun 2007 10:46:24 +0200
parents e6ebe6853e51
children 9a71ea0c941b
files MoinMoin/_tests/test_events.py
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_events.py	Mon Jun 25 15:05:30 2007 +0200
+++ b/MoinMoin/_tests/test_events.py	Tue Jun 26 10:46:24 2007 +0200
@@ -10,7 +10,9 @@
 
 import MoinMoin.events as events
 import MoinMoin.events.notification as notification
+import MoinMoin.events.jabbernotify as jabbernotify
 from MoinMoin.Page import Page
+from MoinMoin.user import User
 
 def test_get_handlers(request):
     """Test if there are any event handlers. There should be some internal ones"""
@@ -45,4 +47,40 @@
     py.test.raises(notification.UnknownChangeType, notification.page_change_message, 
                    "StupidType", request, page, "en", revisions=page.getRevList())
     
+def test_filter_subscriber_list(request):
+    user = User(request)
+    event = events.Event(request)
+    
+    print "User is subscribed to this event and wants to get notified by jabber."
+    print "This means, that he should stay on the list."
+    user.notify_by_jabber = True
+    user.subscribed_events = [events.Event.__name__]
+    subscribers = {"en": [user]}
+    jabbernotify._filter_subscriber_list(event, subscribers)
+    assert subscribers["en"]
+    
+    print "User is subscribed to this event, but doesn't want to get notified by jabber."
+    print "The list should be empty."
+    user.notify_by_jabber = False
+    user.subscribed_events = [events.Event.__name__]
+    subscribers = {"en": [user]}
+    jabbernotify._filter_subscriber_list(event, subscribers)
+    assert not subscribers["en"]
+    
+    print "User is not subscribed to this event, but wants to get notfied by jabber."
+    print "The list should be empty."
+    user.notify_by_jabber = True
+    user.subscribed_events = []
+    subscribers = {"en": [user]}
+    jabbernotify._filter_subscriber_list(event, subscribers)
+    assert not subscribers["en"]
+    
+    print "User is neither subscribed to this event, nor wants jabber notifications."
+    print "The list should be empty."
+    user.notify_by_jabber = False
+    user.subscribed_events = []
+    subscribers = {"en": [user]}
+    jabbernotify._filter_subscriber_list(event, subscribers)
+    assert not subscribers["en"]
+    
 coverage_modules = ["MoinMoin.events"]