[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup/tests - test_schema.py:1.2.2.1

Fred L. Drake, Jr. fred@zope.com
Fri, 21 Feb 2003 11:31:35 -0500


Update of /cvs-repository/Zope/lib/python/Zope/Startup/tests
In directory cvs.zope.org:/tmp/cvs-serv9050

Modified Files:
      Tag: new-install-branch
	test_schema.py 
Log Message:
Added test of the <cgi-environment> section.


=== Zope/lib/python/Zope/Startup/tests/test_schema.py 1.2 => 1.2.2.1 ===
--- Zope/lib/python/Zope/Startup/tests/test_schema.py:1.2	Wed Jan 29 15:25:21 2003
+++ Zope/lib/python/Zope/Startup/tests/test_schema.py	Fri Feb 21 11:31:34 2003
@@ -14,8 +14,12 @@
 
 """Test that the Zope schema can be loaded."""
 
+import os
+import StringIO
+import tempfile
 import unittest
 
+import ZConfig
 import Zope.Startup
 
 
@@ -23,6 +27,29 @@
 
     def test_load_schema(self):
         Zope.Startup.getSchema()
+
+    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 = StringIO.StringIO("""\
+            # instancehome is here since it's required
+            instancehome %s
+            <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_suite():