view MoinMoin/_tests/ @ 2327:e6ebe6853e51

Unit test; check if page_change_message() raises an exception.
author Karol Nowak <>
date Mon, 25 Jun 2007 15:05:30 +0200
parents 062b76cf8d48
children 495b09143c10
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - tests for module

    @copyright: 2007 by Karol Nowak <>
    @license: GNU GPL, see COPYING for details.

import py

import as events
import as notification
from MoinMoin.Page import Page

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

    assert events.get_handlers(request.cfg)

def test_send_event(request):
    """Test if event handlers are called and if proper messages are returned"""
    return_string = u"test_send_event"
    def event_handler(event):
        return notification.Failure("Just a test")
    request.cfg.event_handlers = [event_handler]
    event = events.Event(request)
    print "A proper event handler must be called and an 1-element list of results returned"
    results = events.send_event(event)
    assert issubclass(results[0].__class__, events.EventResult)

def test_subscribable_events(request):
    """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()

def test_page_change_message(request):
    page = Page(request, "FrontPage")
    print "Provided with a dumb change type argument, this should raise an exception!"
    py.test.raises(notification.UnknownChangeType, notification.page_change_message, 
                   "StupidType", request, page, "en", revisions=page.getRevList())
coverage_modules = [""]