changeset 2311:1833361481ff

Some unit test for the MoinMoin.events module.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Fri, 22 Jun 2007 17:58:06 +0200
parents d6333a20bc06
children a85d51778eda
files MoinMoin/_tests/test_events.py
diffstat 1 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/_tests/test_events.py	Fri Jun 22 17:58:06 2007 +0200
@@ -0,0 +1,37 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - tests for MoinMoin.events module
+
+    @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.request.CLI import Request
+import MoinMoin.events as events
+
+def test_get_handlers():
+    """Test if there are any event handlers. There should be some internal ones"""
+    
+    request = Request()
+    assert(events.get_handlers(request.cfg))
+
+def test_send_event():
+    """Test if event handlers are called and if proper messages are returned"""
+    
+    return_string = u"test_send_event"
+    
+    def event_handler(event):
+        return return_string
+    
+    request = Request()
+    request.cfg.event_handlers = [event_handler]
+    event = events.Event(request)
+    
+    print "A proper event handler should be called, and an 1-element list of messages returned"
+    assert(events.send_event(event)[0] == return_string)
+
+def test_subscribable_events():
+    """Test if there are any subscribable events. There should be some."""
+    
+    print "There should be at least a few subscribable events!"
+    assert(events.get_subscribable_events())