[Zope-Checkins] CVS: Zope3/lib/python/Zope/StartUp/tests - testRegisterRequestFactory.py:1.1.2.3 testRequestFactoryRegistry.py:1.1.2.3 testServerTypeRegistry.py:1.1.2.3 testStartupDirectives.py:1.1.2.5
Guido van Rossum
guido@python.org
Tue, 4 Jun 2002 14:59:29 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/StartUp/tests
In directory cvs.zope.org:/tmp/cvs-serv1575/lib/python/Zope/StartUp/tests
Modified Files:
Tag: Zope-3x-branch
testRegisterRequestFactory.py testRequestFactoryRegistry.py
testServerTypeRegistry.py testStartupDirectives.py
Log Message:
Whoever (not Jeremy :-) checks in files from Windows with the CRLF
markers still left in, please stop doing this. It screws up the
checkouts for everyone else (including Windows users who use the
command line cvs tools). Hint: some wincvs do this.
=== Zope3/lib/python/Zope/StartUp/tests/testRegisterRequestFactory.py 1.1.2.2 => 1.1.2.3 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-import unittest
-from Zope.StartUp.RequestFactoryRegistry import getRequestFactory
-
-from Zope.Configuration.xmlconfig import xmlconfig
-from cStringIO import StringIO
-
-
-template = """<zopeConfigure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:startup='http://namespaces.zope.org/startup'>
- %s
- </zopeConfigure>"""
-
-
-class Test( unittest.TestCase ):
-
-
- def testRegisterRequestFactory(self):
-
- xmlconfig(StringIO(template % (
- '''
- <directive name="registerRequestFactory"
- attributes="name, publication, request"
- handler="Zope.StartUp.metaConfigure.registerRequestFactory"
- namespace="http://namespaces.zope.org/startup" />
-
- <startup:registerRequestFactory name="BrowserRequestFactory"
- publication =
- "Zope.App.ZopePublication.Browser.Publication.BrowserPublication"
- request = "Zope.Publisher.Browser.BrowserRequest." />
- '''
- )))
-
- from Zope.App.ZopePublication.Browser.Publication import \
- BrowserPublication
- from Zope.Publisher.Browser.BrowserRequest import BrowserRequest
-
- self.assertEqual(
- getRequestFactory('BrowserRequestFactory')._pubFactory,
- BrowserPublication)
- self.assertEqual(
- getRequestFactory('BrowserRequestFactory')._request,
- BrowserRequest)
-
-
-
-def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase( Test )
-
-
-if __name__=='__main__':
- unittest.TextTestRunner().run( test_suite() )
-
+"""
+
+$Id$
+"""
+
+import unittest
+from Zope.StartUp.RequestFactoryRegistry import getRequestFactory
+
+from Zope.Configuration.xmlconfig import xmlconfig
+from cStringIO import StringIO
+
+
+template = """<zopeConfigure
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:startup='http://namespaces.zope.org/startup'>
+ %s
+ </zopeConfigure>"""
+
+
+class Test( unittest.TestCase ):
+
+
+ def testRegisterRequestFactory(self):
+
+ xmlconfig(StringIO(template % (
+ '''
+ <directive name="registerRequestFactory"
+ attributes="name, publication, request"
+ handler="Zope.StartUp.metaConfigure.registerRequestFactory"
+ namespace="http://namespaces.zope.org/startup" />
+
+ <startup:registerRequestFactory name="BrowserRequestFactory"
+ publication =
+ "Zope.App.ZopePublication.Browser.Publication.BrowserPublication"
+ request = "Zope.Publisher.Browser.BrowserRequest." />
+ '''
+ )))
+
+ from Zope.App.ZopePublication.Browser.Publication import \
+ BrowserPublication
+ from Zope.Publisher.Browser.BrowserRequest import BrowserRequest
+
+ self.assertEqual(
+ getRequestFactory('BrowserRequestFactory')._pubFactory,
+ BrowserPublication)
+ self.assertEqual(
+ getRequestFactory('BrowserRequestFactory')._request,
+ BrowserRequest)
+
+
+
+def test_suite():
+ loader = unittest.TestLoader()
+ return loader.loadTestsFromTestCase( Test )
+
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run( test_suite() )
+
=== Zope3/lib/python/Zope/StartUp/tests/testRequestFactoryRegistry.py 1.1.2.2 => 1.1.2.3 ===
#
##############################################################################
-"""
-I do not think it is necessary to do the entire SimpleRegistry tests again.
-Instead we will test whether the module in itself works.
-
-$Id$
-"""
-
-import unittest
-from Zope.StartUp.RequestFactoryRegistry import \
- registerRequestFactory, getRequestFactory
-from Zope.StartUp.RequestFactory import IRequestFactory
-
-
-class RequestFactory:
- """RequestFactory Stub."""
-
- __implements__ = IRequestFactory
-
-
-
-class Test( unittest.TestCase ):
-
-
- def testRegistry(self):
-
- factory = RequestFactory()
-
- registerRequestFactory('factory', factory)
- self.assertEqual(getRequestFactory('factory'), factory)
-
-
-def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase( Test )
-
-
-if __name__=='__main__':
- unittest.TextTestRunner().run( test_suite() )
-
+"""
+I do not think it is necessary to do the entire SimpleRegistry tests again.
+Instead we will test whether the module in itself works.
+
+$Id$
+"""
+
+import unittest
+from Zope.StartUp.RequestFactoryRegistry import \
+ registerRequestFactory, getRequestFactory
+from Zope.StartUp.RequestFactory import IRequestFactory
+
+
+class RequestFactory:
+ """RequestFactory Stub."""
+
+ __implements__ = IRequestFactory
+
+
+
+class Test( unittest.TestCase ):
+
+
+ def testRegistry(self):
+
+ factory = RequestFactory()
+
+ registerRequestFactory('factory', factory)
+ self.assertEqual(getRequestFactory('factory'), factory)
+
+
+def test_suite():
+ loader = unittest.TestLoader()
+ return loader.loadTestsFromTestCase( Test )
+
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run( test_suite() )
+
=== Zope3/lib/python/Zope/StartUp/tests/testServerTypeRegistry.py 1.1.2.2 => 1.1.2.3 ===
#
##############################################################################
-"""
-I do not think it is necessary to do the entire SimpleRegistry tests again.
-Instead we will test whether the module in itself works.
-
-$Id$
-"""
-
-import unittest
-from Zope.StartUp.ServerTypeRegistry import \
- registerServerType, getServerType
-from Zope.StartUp.ServerType import IServerType
-
-
-class ServerType:
- """ServerType Stub."""
-
- __implements__ = IServerType
-
-
-
-class Test( unittest.TestCase ):
-
-
- def testRegistry(self):
-
- server = ServerType()
-
- registerServerType('server', server)
- self.assertEqual(getServerType('server'), server)
-
-
-def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase( Test )
-
-
-if __name__=='__main__':
- unittest.TextTestRunner().run( test_suite() )
-
+"""
+I do not think it is necessary to do the entire SimpleRegistry tests again.
+Instead we will test whether the module in itself works.
+
+$Id$
+"""
+
+import unittest
+from Zope.StartUp.ServerTypeRegistry import \
+ registerServerType, getServerType
+from Zope.StartUp.ServerType import IServerType
+
+
+class ServerType:
+ """ServerType Stub."""
+
+ __implements__ = IServerType
+
+
+
+class Test( unittest.TestCase ):
+
+
+ def testRegistry(self):
+
+ server = ServerType()
+
+ registerServerType('server', server)
+ self.assertEqual(getServerType('server'), server)
+
+
+def test_suite():
+ loader = unittest.TestLoader()
+ return loader.loadTestsFromTestCase( Test )
+
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run( test_suite() )
+
=== Zope3/lib/python/Zope/StartUp/tests/testStartupDirectives.py 1.1.2.4 => 1.1.2.5 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-import unittest, sys, tempfile
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-from Zope.StartUp.metaConfigure import SiteDefinition
-from Zope.Configuration.name import resolve
-
-class ContextStub:
-
- def resolve(self, dottedname):
- return resolve(dottedname)
-
-
-class Test(CleanUp, unittest.TestCase):
-
-
- def _createBlankSiteDefinition(self):
- """ """
- return SiteDefinition('', 'Example Site', 4)
-
-
- def testStorageMethods(self):
- """ """
- sd = self._createBlankSiteDefinition()
-
- self.assertEqual(sd.useFileStorage(ContextStub()), [])
- self.assertEqual(sd._zodb._storage.__class__.__name__, 'FileStorage')
- self.assertEqual(sd._zodb._storage._file_name, 'Data.fs')
- sd._zodb.close()
-
- filename = tempfile.mktemp()
- self.assertEqual(sd.useFileStorage(ContextStub(), file=filename), [])
- self.assertEqual(sd._zodb._storage.__class__.__name__, 'FileStorage')
- self.assertEqual(sd._zodb._storage._file_name, filename)
- sd._zodb.close()
-
- self.assertEqual(sd.useMappingStorage(ContextStub()), [])
- self.assertEqual(sd._zodb._storage.__class__.__name__,
- 'MappingStorage')
-
-
- def testUseLog(self):
- """ """
-
- sd = self._createBlankSiteDefinition()
-
- from zLOG.MinimalLogger import _log_dest
-
- self.assertEqual(sd.useLog(ContextStub()), [])
- self.assertEqual(_log_dest, sys.stderr)
-
- filename = tempfile.mktemp()
- self.assertEqual(sd.useLog(ContextStub(), filename), [])
- from zLOG.MinimalLogger import _log_dest
- self.assertEqual(_log_dest.name, open(filename, 'w').name)
-
-
- def testAddServer(self):
- """ """
-
- sd = self._createBlankSiteDefinition()
-
- from Zope.Configuration.Action import Action
-
- self.assertEqual(sd.addServer(ContextStub(), 'Browser',
- '8081', 'true'), [])
- self.assertEqual(len(sd._servers), 1)
- self.assertEqual(sd._servers.keys(), ['Browser'])
-
- server_info = sd._servers['Browser']
- self.assertEqual(server_info['port'], 8081)
- self.assertEqual(server_info['verbose'], 1)
-
-
- def testInitDB(self):
- """ """
-
- sd = self._createBlankSiteDefinition()
-
-
- from Zope.App.OFS.Content.Folder.RootFolder import IRootFolder
- from Zope.App.ZopePublication.ZopePublication import ZopePublication
-
- filename = tempfile.mktemp()
- sd.useFileStorage(ContextStub(), file=filename)
-
- connection = sd._zodb.open()
- root = connection.root()
- app = root.get(ZopePublication.root_name, None)
- connection.close()
- self.assertEqual(app, None)
-
- sd._initDB()
-
- connection = sd._zodb.open()
- root = connection.root()
- app = root.get(ZopePublication.root_name, None)
- connection.close()
- self.failUnless(IRootFolder.isImplementedBy(app))
-
-
-
-def test_suite():
- loader=unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
+"""
+
+$Id$
+"""
+
+import unittest, sys, tempfile
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.StartUp.metaConfigure import SiteDefinition
+from Zope.Configuration.name import resolve
+
+class ContextStub:
+
+ def resolve(self, dottedname):
+ return resolve(dottedname)
+
+
+class Test(CleanUp, unittest.TestCase):
+
+
+ def _createBlankSiteDefinition(self):
+ """ """
+ return SiteDefinition('', 'Example Site', 4)
+
+
+ def testStorageMethods(self):
+ """ """
+ sd = self._createBlankSiteDefinition()
+
+ self.assertEqual(sd.useFileStorage(ContextStub()), [])
+ self.assertEqual(sd._zodb._storage.__class__.__name__, 'FileStorage')
+ self.assertEqual(sd._zodb._storage._file_name, 'Data.fs')
+ sd._zodb.close()
+
+ filename = tempfile.mktemp()
+ self.assertEqual(sd.useFileStorage(ContextStub(), file=filename), [])
+ self.assertEqual(sd._zodb._storage.__class__.__name__, 'FileStorage')
+ self.assertEqual(sd._zodb._storage._file_name, filename)
+ sd._zodb.close()
+
+ self.assertEqual(sd.useMappingStorage(ContextStub()), [])
+ self.assertEqual(sd._zodb._storage.__class__.__name__,
+ 'MappingStorage')
+
+
+ def testUseLog(self):
+ """ """
+
+ sd = self._createBlankSiteDefinition()
+
+ from zLOG.MinimalLogger import _log_dest
+
+ self.assertEqual(sd.useLog(ContextStub()), [])
+ self.assertEqual(_log_dest, sys.stderr)
+
+ filename = tempfile.mktemp()
+ self.assertEqual(sd.useLog(ContextStub(), filename), [])
+ from zLOG.MinimalLogger import _log_dest
+ self.assertEqual(_log_dest.name, open(filename, 'w').name)
+
+
+ def testAddServer(self):
+ """ """
+
+ sd = self._createBlankSiteDefinition()
+
+ from Zope.Configuration.Action import Action
+
+ self.assertEqual(sd.addServer(ContextStub(), 'Browser',
+ '8081', 'true'), [])
+ self.assertEqual(len(sd._servers), 1)
+ self.assertEqual(sd._servers.keys(), ['Browser'])
+
+ server_info = sd._servers['Browser']
+ self.assertEqual(server_info['port'], 8081)
+ self.assertEqual(server_info['verbose'], 1)
+
+
+ def testInitDB(self):
+ """ """
+
+ sd = self._createBlankSiteDefinition()
+
+
+ from Zope.App.OFS.Content.Folder.RootFolder import IRootFolder
+ from Zope.App.ZopePublication.ZopePublication import ZopePublication
+
+ filename = tempfile.mktemp()
+ sd.useFileStorage(ContextStub(), file=filename)
+
+ connection = sd._zodb.open()
+ root = connection.root()
+ app = root.get(ZopePublication.root_name, None)
+ connection.close()
+ self.assertEqual(app, None)
+
+ sd._initDB()
+
+ connection = sd._zodb.open()
+ root = connection.root()
+ app = root.get(ZopePublication.root_name, None)
+ connection.close()
+ self.failUnless(IRootFolder.isImplementedBy(app))
+
+
+
+def test_suite():
+ loader=unittest.TestLoader()
+ return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run(test_suite())