/usr/share/pyshared/zope/site/tests/test_sitemanagercontainer.py is in python-zope.site 3.9.2-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #############################################################################
#
# Copyright (c) 2009 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""
"""
import unittest
import zope.component
from zope.component import getSiteManager
import zope.container.testing
from zope.event import notify
from zope.lifecycleevent import ObjectRemovedEvent
from zope.lifecycleevent.interfaces import IObjectRemovedEvent
from zope.site.folder import rootFolder
from zope.site.site import SiteManagerContainer
import zope.site.testing
class Dummy(object):
pass
removed_called = False
def removed_event(obj, event):
global removed_called
removed_called = True
def dispatch_event(obj, event):
sm = obj._sm
if sm is not None:
for k,v in sm.items():
notify(ObjectRemovedEvent(v, sm, k))
class SiteManagerContainerTest(unittest.TestCase):
def setUp(self):
self.root = rootFolder()
zope.site.testing.siteSetUp(self.root)
global removed_called
removed_called = False
sm = getSiteManager()
sm.registerHandler(removed_event, (Dummy, IObjectRemovedEvent))
sm.registerHandler(
dispatch_event, (SiteManagerContainer, IObjectRemovedEvent))
def tearDown(self):
zope.site.testing.siteTearDown()
def removed_event(self, event):
self.removed_called = True
def test_delete_smc_should_propagate_removed_event(self):
container = SiteManagerContainer()
self.root['container'] = container
zope.site.testing.createSiteManager(container)
container.getSiteManager()['child'] = Dummy()
del self.root['container']
self.assert_(removed_called)
def test_delete_when_smc_has_no_sitemanager(self):
container = SiteManagerContainer()
self.root['container'] = container
try:
del self.root['container']
except Exception, e:
self.fail(e)
def test_suite():
return unittest.makeSuite(SiteManagerContainerTest)
|