Back to index

moin  1.9.0~rc2
Functions | Variables
test_events Namespace Reference

Functions

def test_get_handlers
def test_send_event
def test_subscribable_events
def test_page_change_message
def test_user_created_event
def test_filter_subscriber_list

Variables

list coverage_modules = ["MoinMoin.events"]
 sent

Function Documentation

Definition at line 67 of file test_events.py.

00067 
00068 def test_filter_subscriber_list(request):
00069     user = User(request)
00070     event = events.Event(request)
00071 
00072     print "User is subscribed to this event on jabber."
00073     print "This means, that he should stay on the list."
00074     user.jid = "user@example.com"
00075     user.jabber_subscribed_events = [events.Event.__name__]
00076     subscribers = {"en": [user]}
00077     notification.filter_subscriber_list(event, subscribers, True)
00078     assert subscribers["en"]
00079 
00080     print "User is not subscribed to this event on jabber."
00081     print "The list should be empty."
00082     user.jid = "user@example.com"
00083     user.jabber_subscribed_events = []
00084     subscribers = {"en": [user]}
00085     notification.filter_subscriber_list(event, subscribers, True)
00086     assert not subscribers["en"]
00087 
00088     print "User is subscribed to this event on email."
00089     print "This means, that he should stay on the list."
00090     user.email = "user@example.com"
00091     user.email_subscribed_events = [events.Event.__name__]
00092     subscribers = {"en": [user]}
00093     notification.filter_subscriber_list(event, subscribers, False)
00094     assert subscribers["en"]
00095 
00096     print "User is not subscribed to this event on email."
00097     print "The list should be empty."
00098     user.email = "user@example.com"
00099     user.email_subscribed_events = []
00100     subscribers = {"en": [user]}
00101     notification.filter_subscriber_list(event, subscribers, False)
00102     assert not subscribers["en"]

def test_events.test_get_handlers (   request)
Test if there are any event handlers. There should be some internal ones

Definition at line 17 of file test_events.py.

00017 
00018 def test_get_handlers(request):
00019     """Test if there are any event handlers. There should be some internal ones"""
00020 
00021     assert events.get_handlers(request.cfg)

Definition at line 44 of file test_events.py.

00044 
00045 def test_page_change_message(request):
00046     page = Page(request, "FrontPage")
00047 
00048     print "Provided with a dumb change type argument, this should raise an exception!"
00049     py.test.raises(notification.UnknownChangeType, notification.page_change_message,
00050                    "StupidType", request, page, "en", revisions=page.getRevList())

def test_events.test_send_event (   request)
Test if event handlers are called and if proper messages are returned

Definition at line 22 of file test_events.py.

00022 
00023 def test_send_event(request):
00024     """Test if event handlers are called and if proper messages are returned"""
00025 
00026     py.test.skip('broken test - global state is changed somehow that test_GetVal looks broken')
00027     return_string = u"test_send_event"
00028 
00029     def event_handler(event):
00030         return notification.Failure("Just a test")
00031 
00032     request.cfg.event_handlers = [event_handler]
00033     event = events.Event(request)
00034 
00035     print "A proper event handler must be called and an 1-element list of results returned"
00036     results = events.send_event(event)
00037     assert issubclass(results[0].__class__, events.EventResult)

Test if there are any subscribable events. There should be some.

Definition at line 38 of file test_events.py.

00038 
00039 def test_subscribable_events(request):
00040     """Test if there are any subscribable events. There should be some."""
00041 
00042     print "There should be at least a few subscribable events!"
00043     assert events.get_subscribable_events()

Definition at line 51 of file test_events.py.

00051 
00052 def test_user_created_event(request):
00053     py.test.skip("Test is wrong, because it assumes send_notification will be called - but if there is no superuser subscribed to UserCreatedEvent, then no notification needs to be sent.")
00054     class server_dummy:
00055         def __init__(self):
00056             self.sent = False
00057 
00058         def send_notification(self, *args):
00059             self.sent = True
00060 
00061     event = events.UserCreatedEvent(request, User(request))
00062     request.cfg.notification_server = server_dummy()
00063     request.cfg.secrets = "thisisnotsecret"
00064 
00065     jabbernotify.handle_user_created(event)
00066     assert request.cfg.notification_server.sent is True


Variable Documentation

list test_events.coverage_modules = ["MoinMoin.events"]

Definition at line 103 of file test_events.py.

Definition at line 55 of file test_events.py.