[Zope3-checkins] CVS: Zope3/lib/python/Zope/ObjectHub/tests - testHubEvent.py:1.1 testObjectHub.py:1.7 testRuidObjectEvent.py:NONE
Godefroid Chapelle
gotcha@swing.be
Thu, 22 Aug 2002 13:05:25 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ObjectHub/tests
In directory cvs.zope.org:/tmp/cvs-serv11633/tests
Modified Files:
testObjectHub.py
Added Files:
testHubEvent.py
Removed Files:
testRuidObjectEvent.py
Log Message:
Refactored inheritance of internal hub events.
Renamed from RuidObjectEvents to HubEvents.
=== Added File Zope3/lib/python/Zope/ObjectHub/tests/testHubEvent.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Revision information:
$Id: testHubEvent.py,v 1.1 2002/08/22 17:05:24 gotcha Exp $
"""
import unittest, sys
from Zope.ObjectHub.HubEvent import ObjectRegisteredHubEvent
from Zope.ObjectHub.HubEvent import ObjectUnregisteredHubEvent
from Zope.ObjectHub.HubEvent import ObjectAddedHubEvent
from Zope.ObjectHub.HubEvent import ObjectModifiedHubEvent
from Zope.ObjectHub.HubEvent import ObjectMovedHubEvent
from Zope.ObjectHub.HubEvent import ObjectRemovedHubEvent
from Zope.Exceptions import NotFoundError
class DummyObjectHub:
def __init__(self, ruid, obj):
self.ruid = ruid
self.obj = obj
def getObject(self, ruid):
if ruid==self.ruid:
return self.obj
raise NotFoundError
class TestObjectAddedHubEvent(unittest.TestCase):
location = '/some/location'
ruid = 23
obj = object()
klass = ObjectAddedHubEvent
def setUp(self):
objecthub = DummyObjectHub(self.ruid, self.obj)
self.event = self.klass(objecthub, self.ruid, self.location)
def testGetLocation(self):
"Test getLocation method"
self.assertEqual(self.event.getLocation(), self.location)
def testGetRuid(self):
"Test getRuid method"
self.assertEqual(self.event.getRuid(), self.ruid)
def testGetObject(self):
"Test getObject method"
self.assertEqual(self.event.getObject(), self.obj)
class TestObjectRegisteredHubEvent(TestObjectAddedHubEvent):
klass = ObjectRegisteredHubEvent
class TestObjectUnregisteredHubEvent(TestObjectAddedHubEvent):
klass = ObjectUnregisteredHubEvent
class TestObjectModifiedHubEvent(TestObjectAddedHubEvent):
klass = ObjectModifiedHubEvent
class TestObjectMovedHubEvent(TestObjectAddedHubEvent):
klass = ObjectMovedHubEvent
class TestObjectRemovedHubEvent(TestObjectAddedHubEvent):
klass = ObjectRemovedHubEvent
def setUp(self):
self.event = self.klass(self.obj, self.ruid, self.location)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestObjectAddedHubEvent),
unittest.makeSuite(TestObjectRegisteredHubEvent),
unittest.makeSuite(TestObjectUnregisteredHubEvent),
unittest.makeSuite(TestObjectModifiedHubEvent),
unittest.makeSuite(TestObjectMovedHubEvent),
unittest.makeSuite(TestObjectRemovedHubEvent),
))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py:1.6 Sun Jul 7 16:32:32 2002
+++ Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py Thu Aug 22 13:05:24 2002
@@ -26,14 +26,14 @@
from Zope.Event.ISubscriber import ISubscriber
from Zope.ObjectHub.ObjectHub import ObjectHub, ObjectHubError
-from Zope.ObjectHub.IRuidObjectEvent import IRuidObjectAddedEvent
-from Zope.ObjectHub.IRuidObjectEvent import IRuidObjectRemovedEvent
-from Zope.ObjectHub.IRuidObjectEvent import IRuidObjectModifiedEvent
-from Zope.ObjectHub.IRuidObjectEvent import IRuidObjectContextChangedEvent
-from Zope.ObjectHub.IRuidObjectEvent import IRuidObjectRegisteredEvent
-from Zope.ObjectHub.IRuidObjectEvent import IRuidObjectUnregisteredEvent
+from Zope.ObjectHub.IHubEvent import IObjectAddedHubEvent
+from Zope.ObjectHub.IHubEvent import IObjectRemovedHubEvent
+from Zope.ObjectHub.IHubEvent import IObjectModifiedHubEvent
+from Zope.ObjectHub.IHubEvent import IObjectMovedHubEvent
+from Zope.ObjectHub.IHubEvent import IObjectRegisteredHubEvent
+from Zope.ObjectHub.IHubEvent import IObjectUnregisteredHubEvent
-import Zope.ObjectHub.RuidObjectEvent as RuidObjectEvent
+import Zope.ObjectHub.HubEvent as RuidObjectEvent
from Zope.Exceptions import NotFoundError
from types import StringTypes
@@ -105,22 +105,22 @@
else:
location = event.getLocation()
obj = event.getObject()
- removeEvent = RuidObjectEvent.RuidObjectRemovedEvent(
+ removeEvent = RuidObjectEvent.ObjectRemovedHubEvent(
obj, ruid, location)
self.hub.notify(removeEvent)
self.hub.unregister(location)
-class TransmitRuidObjectEventTest(unittest.TestCase):
+class TransmitHubEventTest(unittest.TestCase):
ruid = 23
location = '/foo/bar'
- # Don't test the RuidObjectEvent base class.
+ # Don't test the HubtEvent base class.
# See below for testing subclasses / subinterfaces
- # klass = RuidObjectEvent
- # interface = IRuidObjectEvent
+ # klass = HubEvent
+ # interface = IHubEvent
def setUp(self):
self.object_hub = ObjectHub()
- self.ruidobject_event = self.klass(self.object_hub,
+ self.hub_event = self.klass(self.object_hub,
self.ruid,
self.location)
@@ -128,37 +128,37 @@
self.object_hub.subscribe(self.subscriber)
def testTransmittedEvent(self):
- """Test that the RuidObjectEvents are transmitted by the notify method
+ """Test that the HubEvents are transmitted by the notify method
"""
- self.object_hub.notify(self.ruidobject_event)
+ self.object_hub.notify(self.hub_event)
self.subscriber.verifyEventsReceived(self, [
(self.interface, self.ruid, self.location)
])
-class TransmitRuidObjectAddedEventTest(TransmitRuidObjectEventTest):
- interface = IRuidObjectAddedEvent
- klass = RuidObjectEvent.RuidObjectAddedEvent
-
-class TransmitRuidObjectRemovedEventTest(TransmitRuidObjectEventTest):
- interface = IRuidObjectRemovedEvent
- klass = RuidObjectEvent.RuidObjectRemovedEvent
-
-class TransmitRuidObjectModifiedEventTest(TransmitRuidObjectEventTest):
- interface = IRuidObjectModifiedEvent
- klass = RuidObjectEvent.RuidObjectModifiedEvent
-
-class TransmitRuidObjectContextChangedEventTest(TransmitRuidObjectEventTest):
- interface = IRuidObjectContextChangedEvent
- klass = RuidObjectEvent.RuidObjectContextChangedEvent
-
-class TransmitRuidObjectRegisteredEventTest(TransmitRuidObjectEventTest):
- interface = IRuidObjectRegisteredEvent
- klass = RuidObjectEvent.RuidObjectRegisteredEvent
-
-class TransmitRuidObjectUnregisteredEventTest(TransmitRuidObjectEventTest):
- interface = IRuidObjectUnregisteredEvent
- klass = RuidObjectEvent.RuidObjectUnregisteredEvent
+class TransmitObjectAddedHubEventTest(TransmitHubEventTest):
+ interface = IObjectAddedHubEvent
+ klass = RuidObjectEvent.ObjectAddedHubEvent
+
+class TransmitObjectRemovedHubEventTest(TransmitHubEventTest):
+ interface = IObjectRemovedHubEvent
+ klass = RuidObjectEvent.ObjectRemovedHubEvent
+
+class TransmitObjectModifiedHubEventTest(TransmitHubEventTest):
+ interface = IObjectModifiedHubEvent
+ klass = RuidObjectEvent.ObjectModifiedHubEvent
+
+class TransmitObjectMovedHubEventTest(TransmitHubEventTest):
+ interface = IObjectMovedHubEvent
+ klass = RuidObjectEvent.ObjectMovedHubEvent
+
+class TransmitObjectRegisteredHubEventTest(TransmitHubEventTest):
+ interface = IObjectRegisteredHubEvent
+ klass = RuidObjectEvent.ObjectRegisteredHubEvent
+
+class TransmitObjectUnregisteredHubEventTest(TransmitHubEventTest):
+ interface = IObjectUnregisteredHubEvent
+ klass = RuidObjectEvent.ObjectUnregisteredHubEvent
class BasicHubTest(unittest.TestCase):
@@ -172,7 +172,6 @@
self.subscriber = LoggingSubscriber()
self.object_hub.subscribe(self.subscriber)
-
def setEvents(self):
self.added_event = ObjectAddedEvent(self.location)
self.added_new_location_event = ObjectAddedEvent(self.new_location)
@@ -192,8 +191,8 @@
ruid2 = self.object_hub.register(self.new_location)
self.subscriber.verifyEventsReceived(self, [
- (IRuidObjectRegisteredEvent, ruid, self.location),
- (IRuidObjectRegisteredEvent, ruid2, self.new_location)
+ (IObjectRegisteredHubEvent, ruid, self.location),
+ (IObjectRegisteredHubEvent, ruid2, self.new_location)
])
# register again and check for error
@@ -204,12 +203,12 @@
# unregister first object by location
self.object_hub.unregister(self.location)
self.subscriber.verifyEventsReceived(self, [
- (IRuidObjectUnregisteredEvent, ruid, self.location)
+ (IObjectUnregisteredHubEvent, ruid, self.location)
])
# unregister second object by ruid
self.object_hub.unregister(ruid2)
self.subscriber.verifyEventsReceived(self, [
- (IRuidObjectUnregisteredEvent, ruid2, self.new_location)
+ (IObjectUnregisteredHubEvent, ruid2, self.new_location)
])
def testRegistrationRelativeLocation(self):
@@ -265,8 +264,8 @@
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
- (IRuidObjectRegisteredEvent, ruid, location),
- (IRuidObjectAddedEvent, ruid, location),
+ (IObjectRegisteredHubEvent, ruid, location),
+ (IObjectAddedHubEvent, ruid, location),
])
@@ -337,11 +336,11 @@
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
- (IRuidObjectRegisteredEvent, ruid, location),
- (IRuidObjectAddedEvent, ruid, location),
+ (IObjectRegisteredHubEvent, ruid, location),
+ (IObjectAddedHubEvent, ruid, location),
(IObjectRemovedEvent, location),
- (IRuidObjectRemovedEvent, ruid, location, obj),
- (IRuidObjectUnregisteredEvent, ruid, location),
+ (IObjectRemovedHubEvent, ruid, location, obj),
+ (IObjectUnregisteredHubEvent, ruid, location),
])
@@ -398,10 +397,10 @@
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
- (IRuidObjectRegisteredEvent, ruid, location),
- (IRuidObjectAddedEvent, ruid, location),
+ (IObjectRegisteredHubEvent, ruid, location),
+ (IObjectAddedHubEvent, ruid, location),
(IObjectModifiedEvent, location),
- (IRuidObjectModifiedEvent, ruid, location)
+ (IObjectModifiedHubEvent, ruid, location)
])
@@ -457,10 +456,10 @@
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
- (IRuidObjectRegisteredEvent, ruid, location),
- (IRuidObjectAddedEvent, ruid, location),
+ (IObjectRegisteredHubEvent, ruid, location),
+ (IObjectAddedHubEvent, ruid, location),
(IObjectMovedEvent, new_location),
- (IRuidObjectContextChangedEvent, ruid, new_location)
+ (IObjectMovedHubEvent, ruid, new_location)
])
@@ -502,22 +501,22 @@
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
- (IRuidObjectRegisteredEvent, None, location),
- (IRuidObjectAddedEvent, None, location),
+ (IObjectRegisteredHubEvent, None, location),
+ (IObjectAddedHubEvent, None, location),
(IObjectAddedEvent, new_location),
- (IRuidObjectRegisteredEvent, None, new_location),
- (IRuidObjectAddedEvent, None, new_location),
+ (IObjectRegisteredHubEvent, None, new_location),
+ (IObjectAddedHubEvent, None, new_location),
(IObjectMovedEvent, new_location),
])
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(TransmitRuidObjectAddedEventTest),
- unittest.makeSuite(TransmitRuidObjectRemovedEventTest),
- unittest.makeSuite(TransmitRuidObjectModifiedEventTest),
- unittest.makeSuite(TransmitRuidObjectContextChangedEventTest),
- unittest.makeSuite(TransmitRuidObjectRegisteredEventTest),
- unittest.makeSuite(TransmitRuidObjectUnregisteredEventTest),
+ unittest.makeSuite(TransmitObjectAddedHubEventTest),
+ unittest.makeSuite(TransmitObjectRemovedHubEventTest),
+ unittest.makeSuite(TransmitObjectModifiedHubEventTest),
+ unittest.makeSuite(TransmitObjectMovedHubEventTest),
+ unittest.makeSuite(TransmitObjectRegisteredHubEventTest),
+ unittest.makeSuite(TransmitObjectUnregisteredHubEventTest),
unittest.makeSuite(TestRegistrationEvents),
unittest.makeSuite(TestNoRegistration),
unittest.makeSuite(TestObjectAddedEvent),
=== Removed File Zope3/lib/python/Zope/ObjectHub/tests/testRuidObjectEvent.py ===