[Zope-CVS] CVS: Products/Event/tests - testEventRegistry.py:1.3

Martijn Pieters mj@zope.com
Sat, 21 Sep 2002 12:31:09 -0400


Update of /cvs-repository/Products/Event/tests
In directory cvs.zope.org:/tmp/cvs-serv18004/tests

Modified Files:
	testEventRegistry.py 
Log Message:
Simplify Event registration by perusing the available module and class name.


=== Products/Event/tests/testEventRegistry.py 1.2 => 1.3 ===
--- Products/Event/tests/testEventRegistry.py:1.2	Fri Sep 20 11:08:04 2002
+++ Products/Event/tests/testEventRegistry.py	Sat Sep 21 12:31:08 2002
@@ -34,26 +34,29 @@
 
     def test_registerEvent(self):
         registry = self._makeOne()
-        registry.registerEvent('foo', DummyEvent, 'Dummy Event')
+        registry.registerEvent(DummyEvent, 'Dummy Event')
+        key = '%s.%s' % (DummyEvent.__module__, DummyEvent.__name__)
 
         self.assertEqual(len(registry.listEvents()), 1)
-        self.failUnless('foo' in registry.listEvents())
-        self.failUnless(('foo', 'Dummy Event', DummyEvent.__doc__)
+        self.failUnless(key in registry.listEvents())
+        self.failUnless((key, 'Dummy Event', DummyEvent.__doc__)
                         in registry.listEvents(with_metadata=1))
 
-        metadata = registry.getEvent('foo')
+        metadata = registry.getEvent(key)
         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')
+        class Bar(DummyEvent): pass
+
+        registry.registerEvent(Bar, 'Dummy Event (bar)', 'Bar Description')
+        key = '%s.%s' % (Bar.__module__, Bar.__name__)
 
         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)
+        self.failUnless(key in registry.listEvents())
+        self.assertEqual(registry.getEventTitle(key), 'Dummy Event (bar)')
+        self.assertEqual(registry.getEventDescription(key), 'Bar Description')
+        self.failUnless(registry.getEventInterface(key) is Bar)
 
 class ReindentDocstringTest(unittest.TestCase):
     def _reindent(self, doc):