[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/tests - testContainerTraverser.py:1.1.2.1 testIContainer.py:1.1.2.3
Jim Fulton
jim@zope.com
Mon, 4 Mar 2002 16:43:46 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/tests
In directory cvs.zope.org:/tmp/cvs-serv23162/Container/tests
Modified Files:
Tag: Zope-3x-branch
testIContainer.py
Added Files:
Tag: Zope-3x-branch
testContainerTraverser.py
Log Message:
Finished refactoring container manageemnt by moving IContainer and
ContainerTraverser down to Container.
=== Added File Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraverser.py ===
##############################################################################
#
# Copyright (c) 2001 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
##############################################################################
"""
$Id: testContainerTraverser.py,v 1.1.2.1 2002/03/04 21:43:15 jim Exp $
"""
import unittest, sys
from Zope.ComponentArchitecture.tests.Request import Request
from Zope.ComponentArchitecture import provideView
from Zope.App.OFS.Container.ContainerTraverser import ContainerTraverser
from Interface import Interface
from Zope.Exceptions import NotFoundError
from Zope.App.OFS.Container.IContainer import IContainer
from Zope.Testing.CleanUp import CleanUp
class I(Interface): pass
class Container:
__implements__ = IContainer
def __init__(self, **kw):
for k in kw:
setattr(self, k , kw[k])
def getObject(self, name, default=None):
return getattr(self, name, default)
class Request(Request):
def getEffectiveURL(self):
return ''
class View:
def __init__(self, comp):
self._comp = comp
class Test(CleanUp, unittest.TestCase):
def testAttr(self):
""" test container traver """
foo = Container()
c = Container( foo=foo )
req = Request( I, '')
T = ContainerTraverser(c)
self.failUnless(T.browser_traverse(req,'foo') is foo)
self.assertRaises(NotFoundError , T.browser_traverse, req ,'morebar')
def testView(self):
""" test getting a view """
foo = Container()
c = Container( foo=foo )
req = Request( I, '')
T = ContainerTraverser(c)
provideView(IContainer, 'foo', I, View)
self.failUnless(T.browser_traverse(req,'foo;view').__class__ is View )
self.failUnless(T.browser_traverse(req,'foo') is foo)
self.assertRaises(NotFoundError , T.browser_traverse, req, 'morebar')
self.assertRaises(NotFoundError , T.browser_traverse, req,
'morebar;view')
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())
=== Zope3/lib/python/Zope/App/OFS/Container/tests/testIContainer.py 1.1.2.2 => 1.1.2.3 ===
from unittest import TestCase, TestSuite, main, makeSuite
-from Zope.App.OFS.IContainer import IContainer
+from Zope.App.OFS.Container.IContainer import IContainer
from Interface import verify
class BaseTestIContainer: