[Zope-CVS] CVS: Products/Event/tests - testEventRegistry.py:1.1
Martijn Pieters
mj@zope.com
Thu, 19 Sep 2002 20:03:42 -0400
Update of /cvs-repository/Products/Event/tests
In directory cvs.zope.org:/tmp/cvs-serv26579/tests
Added Files:
testEventRegistry.py
Log Message:
This time round, actually add the new files.
=== Added File Products/Event/tests/testEventRegistry.py ===
import unittest
class DummyEvent:
"""Dummy Event semi-interface."""
class EventRegistryTests(unittest.TestCase):
oldRegistry = None
def setUp(self):
self._clearRegistry()
def tearDown(self):
self._clearRegistry()
def _clearRegistry(self):
from Products.Event.EventRegistry import _registry
if self.oldRegistry is None:
self.oldRegistry = _registry.copy()
_registry.clear()
else:
_registry.clear()
_registry.update(self.oldRegistry)
def _makeOne(self):
from Products.Event import eventRegistry
return eventRegistry
def test_empty(self):
registry = self._makeOne()
self.assertEqual(len(registry.listEvents()), 0)
self.assertEqual(registry.getEvent('foo'), None)
def test_registerEvent(self):
registry = self._makeOne()
registry.registerEvent('foo', DummyEvent, 'Dummy Event')
self.assertEqual(len(registry.listEvents()), 1)
self.failUnless('foo' in registry.listEvents())
self.failUnless(('foo', 'Dummy Event', DummyEvent.__doc__)
in registry.listEvents(with_metadata=1))
metadata = registry.getEvent('foo')
self.assertEqual(metadata['title'], 'Dummy Event')
self.assertEqual(metadata['description'], DummyEvent.__doc__)
self.failUnless(metadata['interface'] is DummyEvent)
registry.registerEvent('bar', DummyEvent, 'Dummy Event (bar)',
'Bar Description')
self.assertEqual(len(registry.listEvents()), 2)
self.failUnless('bar' in registry.listEvents())
self.assertEqual(registry.getEventTitle('bar'), 'Dummy Event (bar)')
self.assertEqual(registry.getEventDescription('bar'), 'Bar Description')
self.failUnless(registry.getEventInterface('bar') is DummyEvent)