comparison MoinMoin/_tests/test_events.py @ 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 10be78f1fa97
comparison
equal deleted inserted replaced
2327:e6ebe6853e51 2328:495b09143c10
8 8
9 import py 9 import py
10 10
11 import MoinMoin.events as events 11 import MoinMoin.events as events
12 import MoinMoin.events.notification as notification 12 import MoinMoin.events.notification as notification
13 import MoinMoin.events.jabbernotify as jabbernotify
13 from MoinMoin.Page import Page 14 from MoinMoin.Page import Page
15 from MoinMoin.user import User
14 16
15 def test_get_handlers(request): 17 def test_get_handlers(request):
16 """Test if there are any event handlers. There should be some internal ones""" 18 """Test if there are any event handlers. There should be some internal ones"""
17 19
18 assert events.get_handlers(request.cfg) 20 assert events.get_handlers(request.cfg)
43 45
44 print "Provided with a dumb change type argument, this should raise an exception!" 46 print "Provided with a dumb change type argument, this should raise an exception!"
45 py.test.raises(notification.UnknownChangeType, notification.page_change_message, 47 py.test.raises(notification.UnknownChangeType, notification.page_change_message,
46 "StupidType", request, page, "en", revisions=page.getRevList()) 48 "StupidType", request, page, "en", revisions=page.getRevList())
47 49
50 def test_filter_subscriber_list(request):
51 user = User(request)
52 event = events.Event(request)
53
54 print "User is subscribed to this event and wants to get notified by jabber."
55 print "This means, that he should stay on the list."
56 user.notify_by_jabber = True
57 user.subscribed_events = [events.Event.__name__]
58 subscribers = {"en": [user]}
59 jabbernotify._filter_subscriber_list(event, subscribers)
60 assert subscribers["en"]
61
62 print "User is subscribed to this event, but doesn't want to get notified by jabber."
63 print "The list should be empty."
64 user.notify_by_jabber = False
65 user.subscribed_events = [events.Event.__name__]
66 subscribers = {"en": [user]}
67 jabbernotify._filter_subscriber_list(event, subscribers)
68 assert not subscribers["en"]
69
70 print "User is not subscribed to this event, but wants to get notfied by jabber."
71 print "The list should be empty."
72 user.notify_by_jabber = True
73 user.subscribed_events = []
74 subscribers = {"en": [user]}
75 jabbernotify._filter_subscriber_list(event, subscribers)
76 assert not subscribers["en"]
77
78 print "User is neither subscribed to this event, nor wants jabber notifications."
79 print "The list should be empty."
80 user.notify_by_jabber = False
81 user.subscribed_events = []
82 subscribers = {"en": [user]}
83 jabbernotify._filter_subscriber_list(event, subscribers)
84 assert not subscribers["en"]
85
48 coverage_modules = ["MoinMoin.events"] 86 coverage_modules = ["MoinMoin.events"]