[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup/tests - test_schema.py:1.2.2.4
Fred L. Drake, Jr.
fred@zope.com
Tue, 18 Mar 2003 14:32:22 -0500
Update of /cvs-repository/Zope/lib/python/Zope/Startup/tests
In directory cvs.zope.org:/tmp/cvs-serv9737
Modified Files:
Tag: new-install-branch
test_schema.py
Log Message:
- refactored confuration text loading into a helper method
- added simple test of the access/trace log configuration
=== Zope/lib/python/Zope/Startup/tests/test_schema.py 1.2.2.3 => 1.2.2.4 ===
--- Zope/lib/python/Zope/Startup/tests/test_schema.py:1.2.2.3 Tue Mar 18 13:46:04 2003
+++ Zope/lib/python/Zope/Startup/tests/test_schema.py Tue Mar 18 14:32:21 2003
@@ -22,11 +22,30 @@
import ZConfig
import Zope.Startup
+from Zope.Startup import datatypes
+
from App.config import getConfiguration
+TEMPNAME = tempfile.mktemp()
+
+
class StartupTestCase(unittest.TestCase):
+ def load_config_text(self, text):
+ # We have to create a directory of our own since the existence
+ # of the directory is checked. This handles this in a
+ # platform-independent way.
+ schema = Zope.Startup.getSchema()
+ sio = cStringIO.StringIO(
+ text.replace("<<INSTANCE_HOME>>", TEMPNAME))
+ os.mkdir(TEMPNAME)
+ try:
+ conf, handler = ZConfig.loadConfigFile(schema, sio)
+ finally:
+ os.rmdir(TEMPNAME)
+ return conf
+
def test_load_config_template(self):
schema = Zope.Startup.getSchema()
cfg = getConfiguration()
@@ -34,31 +53,35 @@
f = open(fn)
text = f.read()
f.close()
- text = text.replace("<<INSTANCE_HOME>>", cfg.instancehome)
- ZConfig.loadConfigFile(schema, cStringIO.StringIO(text))
+ self.load_config_text(text)
def test_cgi_environment(self):
- schema = Zope.Startup.getSchema()
- # We have to create a directory of our own since the existence
- # of the directory is checked. This handles this in a
- # platform-independent way.
- dn = tempfile.mktemp()
- sio = cStringIO.StringIO("""\
+ conf = self.load_config_text("""\
# instancehome is here since it's required
- instancehome %s
+ instancehome <<INSTANCE_HOME>>
<cgi-environment>
HEADER value
ANOTHER value2
</cgi-environment>
- """ % dn)
- os.mkdir(dn)
- try:
- conf, xxx = ZConfig.loadConfigFile(schema, sio)
- finally:
- os.rmdir(dn)
+ """)
items = conf.cgi_environment.items()
items.sort()
self.assertEqual(items, [("ANOTHER", "value2"), ("HEADER", "value")])
+
+ def test_access_and_trace_logs(self):
+ fn = tempfile.mktemp()
+ conf = self.load_config_text("""
+ instancehome <<INSTANCE_HOME>>
+ <logger access>
+ <logfile>
+ path %s
+ </logfile>
+ </logger>
+ """ % fn)
+ self.assert_(isinstance(conf.access, datatypes.LoggerFactory))
+ self.assertEqual(conf.access.name, "access")
+ self.assertEqual(conf.access.handler_factories[0].section.path, fn)
+ self.assert_(conf.trace is None)
def test_suite():