[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests -
objecthubsetup.py:1.12.24.2 test_eventservice.py:1.27.24.4
test_menu.py:1.2.6.2 test_modulelookup.py:1.3.18.4
test_objecthub.py:1.12.8.4 test_registration.py:1.1.18.2
test_registrationmanager.py:1.2.6.4
test_servicemanager.py:1.15.2.4 test_view.py:1.22.2.6
test_pluggableauth.py:NONE
Jim Fulton
jim at zope.com
Mon Sep 15 14:13:11 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv15511/src/zope/app/services/tests
Modified Files:
Tag: parentgeddon-branch
objecthubsetup.py test_eventservice.py test_menu.py
test_modulelookup.py test_objecthub.py test_registration.py
test_registrationmanager.py test_servicemanager.py
test_view.py
Removed Files:
Tag: parentgeddon-branch
test_pluggableauth.py
Log Message:
Got lots of tests to pass.
Added a setitem helper function to be used to help satisfy container
contracts.
=== Zope3/src/zope/app/services/tests/objecthubsetup.py 1.12.24.1 => 1.12.24.2 ===
--- Zope3/src/zope/app/services/tests/objecthubsetup.py:1.12.24.1 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/objecthubsetup.py Mon Sep 15 14:12:39 2003
@@ -59,7 +59,7 @@
location = canonicalPath(location)
testcase.assert_(interface.isImplementedBy(event),
'Interface %s' % interface.getName())
- testcase.assertEqual(event.location, location)
+ testcase.assertEqual(canonicalPath(event.object), location)
if obj is not None:
testcase.assertEqual(event.object, obj)
@@ -79,8 +79,7 @@
def notify(self, event):
LoggingSubscriber.notify(self, event)
# The policy is to register on object adds and object copies.
- if (IObjectAddedEvent.isImplementedBy(event)
- and not IObjectMovedEvent.isImplementedBy(event)):
+ if IObjectAddedEvent.isImplementedBy(event):
self.hub.register(event.object)
class ObjectHubSetup(EventSetup):
=== Zope3/src/zope/app/services/tests/test_eventservice.py 1.27.24.3 => 1.27.24.4 ===
--- Zope3/src/zope/app/services/tests/test_eventservice.py:1.27.24.3 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_eventservice.py Mon Sep 15 14:12:39 2003
@@ -235,7 +235,7 @@
unsubscribe(2,
event_type=IObjectAddedEvent,
context=self.folder1_1)
- publish(self.folder1, ObjectAddedEvent(None, None, 'foo'))
+ publish(self.folder1, ObjectAddedEvent(None, 'fauxparent', 'foo'))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -687,7 +687,7 @@
subscriber2 = self.folder1Subscriber
filter = DummyFilter()
event = ObjectAddedEvent(foo)
- event2 = ObjectModifiedEvent(None, '/foo')
+ event2 = ObjectModifiedEvent(None)
subscribe(
subscriber)
subscribe(
=== Zope3/src/zope/app/services/tests/test_menu.py 1.2.6.1 => 1.2.6.2 ===
--- Zope3/src/zope/app/services/tests/test_menu.py:1.2.6.1 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_menu.py Mon Sep 15 14:12:39 2003
@@ -79,7 +79,7 @@
item.title = title
item.action = action
item.interface = interface
- menu['something'] = item
+ menu.addItem(item)
return item
=== Zope3/src/zope/app/services/tests/test_modulelookup.py 1.3.18.3 => 1.3.18.4 ===
--- Zope3/src/zope/app/services/tests/test_modulelookup.py:1.3.18.3 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_modulelookup.py Mon Sep 15 14:12:39 2003
@@ -24,8 +24,8 @@
from zope.app.services.registration import RegistrationManagerContainer
from zope.app.interfaces.services.module import IModuleManager
from zope.interface import implements
-from zope.app.container.contained import Contained, contained
-
+from zope.app.container.contained import Contained, setitem
+from zope.app.tests.placelesssetup import setUp, tearDown
class MyModuleManager(object):
implements(IModuleManager)
@@ -38,9 +38,7 @@
class MyFolder(RegistrationManagerContainer, dict, Contained):
def __setitem__(self, name, object):
- object = contained(object, self, name)
- dict.__setitem__(self, name, object)
- return name
+ setitem(self, super(MyFolder, self).__setitem__, name, object)
def test_findMoule():
@@ -85,5 +83,7 @@
1
"""
-def test_suite(): return DocTestSuite()
+def test_suite():
+ return DocTestSuite(setUp=setUp, tearDown=tearDown)
+
if __name__ == '__main__': unittest.main()
=== Zope3/src/zope/app/services/tests/test_objecthub.py 1.12.8.3 => 1.12.8.4 ===
--- Zope3/src/zope/app/services/tests/test_objecthub.py:1.12.8.3 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_objecthub.py Mon Sep 15 14:12:39 2003
@@ -18,12 +18,13 @@
"""
import unittest
+from zope.app import zapi
from zope.app.services.tests.objecthubsetup import ObjectHubSetup
from zope.app.interfaces.event import IObjectModifiedEvent
from zope.app.interfaces.container import IObjectAddedEvent
from zope.app.interfaces.container import IObjectRemovedEvent
-from zope.app.interfaces.container import IObjectAddedEvent
+from zope.app.interfaces.container import IObjectMovedEvent
from zope.app.container.contained import ObjectAddedEvent, ObjectRemovedEvent
from zope.app.container.contained import ObjectMovedEvent
@@ -60,8 +61,7 @@
class TransmitHubEventTest(ObjectHubSetup, unittest.TestCase):
hubid = 23
- location = '/foo/bar'
- obj = object()
+ location = '/folder1/folder1_1'
# Don't test the HubEvent base class.
# See below for testing subclasses / subinterfaces
# klass = HubEvent
@@ -70,6 +70,8 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpLoggingSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
+
self.hub_event = self.klass(self.object_hub,
self.hubid,
self.location,
@@ -98,6 +100,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpLoggingSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.hub_event = self.klass(
self.object_hub, self.hubid,
'/old/location', self.location, self.obj)
@@ -114,35 +117,27 @@
pass
class BasicHubTest(ObjectHubSetup, unittest.TestCase):
- root = Folder()
- directlyProvides(root, IContainmentRoot)
- oldParent = Folder()
- oldParent.__parent__ = root
- oldParent.__name__ = 'foo'
- newParent = Folder()
- newParent.__parent__ = root
- newParent.__name__ = 'baz'
- obj = Folder()
- obj.__parent__ = oldParent
- obj.__name__ = 'bar'
-
+ location = '/folder1/folder1_1'
+ new_location = '/folder2/folder2_1'
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpLoggingSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def setEvents(self):
- self.created_event = ObjectCreatedEvent(object())
- self.added_event = ObjectAddedEvent(self.obj)
- self.added_new_location_event = ObjectAddedEvent(
- self.obj, self.newParent, self.newName)
- self.removed_event = ObjectRemovedEvent(self.obj)
- self.modified_event = ObjectModifiedEvent(self.obj)
+ obj = self.obj
+ self.created_event = ObjectCreatedEvent(obj)
+ self.added_event = ObjectAddedEvent(obj)
+ newobj = zapi.traverse(self.rootFolder, self.new_location)
+ self.added_new_location_event = ObjectAddedEvent(newobj)
+ self.removed_event = ObjectRemovedEvent(obj)
+ self.modified_event = ObjectModifiedEvent(obj)
self.moved_event = ObjectMovedEvent(
- self.obj,
- self.oldParent, self.oldName,
- self.newParent, self.newName,
+ obj,
+ obj.__parent__, obj.__name__,
+ newobj.__parent__, newobj.__name__,
)
class TestRegistrationEvents(BasicHubTest):
@@ -306,6 +301,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpRegistrationSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def testLookingUpLocation(self):
@@ -362,6 +358,7 @@
class TestObjectRemovedEvent(BasicHubTest):
def setUp(self):
ObjectHubSetup.setUp(self)
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setUpRegistrationSubscriber()
self.setEvents()
@@ -414,6 +411,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpRegistrationSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def testModifiedLocation(self):
@@ -471,6 +469,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpRegistrationSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def testMovedLocation(self):
@@ -483,6 +482,16 @@
hub.notify(added_event)
hubid = hub.getHubId(location)
+
+ self.subscriber.verifyEventsReceived(self, [
+ (IObjectAddedEvent, location),
+ (IObjectRegisteredHubEvent, hubid, location),
+ ])
+
+ # simulate moving the object
+ self.obj.__parent__ = zapi.traverse(self.rootFolder, "folder2")
+ self.obj.__name__ = "folder2_1"
+
hub.notify(moved_event)
location_from_hub = hub.getPath(hubid)
@@ -494,8 +503,6 @@
self.assertEqual(hubid2, hubid)
self.subscriber.verifyEventsReceived(self, [
- (IObjectAddedEvent, location),
- (IObjectRegisteredHubEvent, hubid, location),
(IObjectMovedEvent, new_location),
(IObjectMovedHubEvent, hubid, new_location)
])
@@ -516,6 +523,10 @@
self.assertRaises(NotFoundError, hub.getHubId, location)
self.assertRaises(NotFoundError, hub.getHubId, new_location)
+ # simulate moving the object
+ self.obj.__parent__ = zapi.traverse(self.rootFolder, "folder2")
+ self.obj.__name__ = "folder2_1"
+
self.subscriber.verifyEventsReceived(self, [
(IObjectMovedEvent, new_location),
])
@@ -533,13 +544,20 @@
hub.notify(added_event)
hub.notify(added_event2)
- self.assertRaises(ObjectHubError, hub.notify, moved_event)
-
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
(IObjectRegisteredHubEvent, None, location),
(IObjectAddedEvent, new_location),
(IObjectRegisteredHubEvent, None, new_location),
+ ])
+
+ # simulate moving the object
+ self.obj.__parent__ = zapi.traverse(self.rootFolder, "folder2")
+ self.obj.__name__ = "folder2_1"
+
+ self.assertRaises(ObjectHubError, hub.notify, moved_event)
+
+ self.subscriber.verifyEventsReceived(self, [
(IObjectMovedEvent, new_location),
])
=== Zope3/src/zope/app/services/tests/test_registration.py 1.1.18.1 => 1.1.18.2 ===
--- Zope3/src/zope/app/services/tests/test_registration.py:1.1.18.1 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_registration.py Mon Sep 15 14:12:39 2003
@@ -16,6 +16,7 @@
from unittest import makeSuite, main, TestCase
+from zope.app import zapi
from zope.app.services.hub import Registration
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.traversing import traverse, canonicalPath
@@ -47,10 +48,9 @@
def testRegister(self):
self.registrar.subscribe()
self.assertEqual(self.hub.numRegistrations(), 0)
- content = object()
- name = 'blah'
+ content = zapi.traverse(self.rootFolder, "folder1/folder1_1")
- event = ObjectAddedEvent(content, None, canonicalPath('/%s' % name))
+ event = ObjectAddedEvent(content)
self.events.publish(event)
self.assertEqual(self.hub.numRegistrations(), 1)
=== Zope3/src/zope/app/services/tests/test_registrationmanager.py 1.2.6.3 => 1.2.6.4 ===
--- Zope3/src/zope/app/services/tests/test_registrationmanager.py:1.2.6.3 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_registrationmanager.py Mon Sep 15 14:12:39 2003
@@ -25,6 +25,7 @@
from zope.interface.common.tests.basemapping import BaseTestIEnumerableMapping
from zope.interface.verify import verifyObject
from zope.interface import implements
+from zope.app.container.contained import ObjectRemovedEvent
class Undeletable:
@@ -355,6 +356,8 @@
manager = RegistrationManager()
thingy = Undeletable()
manager['xyzzy'] = thingy
+ event = ObjectRemovedEvent(manager, 'xxx', 'yyy')
+ manager.removeNotify(event)
self.failUnless(thingy.was_called)
class RegistrationManagerContainerTests(placefulsetup.PlacefulSetup):
=== Zope3/src/zope/app/services/tests/test_servicemanager.py 1.15.2.3 => 1.15.2.4 ===
--- Zope3/src/zope/app/services/tests/test_servicemanager.py:1.15.2.3 Fri Sep 12 15:15:35 2003
+++ Zope3/src/zope/app/services/tests/test_servicemanager.py Mon Sep 15 14:12:39 2003
@@ -93,7 +93,7 @@
def test_get(self):
sm = traverse(self.rootFolder, '++etc++site')
default = sm.get('default')
- self.assertEqual(default, sm.Packages['default'])
+ self.assertEqual(default, sm['default'])
self.assertEqual(sm.get('spam'), None)
def testAddService(self):
@@ -181,7 +181,7 @@
manager = contained(default['m2'], default, name='m2')
manager.execute()
- self.folder1.setSiteManager(ServiceManager())
+ self.folder1.setSiteManager(ServiceManager(self.folder1))
sm2=getServiceManager(self.folder1)
default = contained(sm2['default'], self.folder1, name='default')
default['m1'] = Manager('zope.app.services.tests.sample1',
=== Zope3/src/zope/app/services/tests/test_view.py 1.22.2.5 => 1.22.2.6 ===
--- Zope3/src/zope/app/services/tests/test_view.py:1.22.2.5 Fri Sep 12 16:46:28 2003
+++ Zope3/src/zope/app/services/tests/test_view.py Mon Sep 15 14:12:39 2003
@@ -235,7 +235,7 @@
def setUp(self):
PlacefulSetup.setUp(self)
self.rootFolder = rootFolder()
- self.rootFolder.setSiteManager(PhonyServiceManager())
+ self.rootFolder.setSiteManager(PhonyServiceManager(self.rootFolder))
default = traverse(self.rootFolder, '++etc++site/default')
self.__template = PhonyTemplate()
default['t'] = self.__template
=== Removed File Zope3/src/zope/app/services/tests/test_pluggableauth.py ===
More information about the Zope3-Checkins
mailing list