[CalendarServer-changes] [744] CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Thu Dec 7 10:40:30 PST 2006


Revision: 744
          http://trac.macosforge.org/projects/calendarserver/changeset/744
Author:   dreid at apple.com
Date:     2006-12-07 10:40:30 -0800 (Thu, 07 Dec 2006)

Log Message:
-----------
Add SACLEnable to config.DEFAULTS and add unittests for config.py, also make root.py use config.SACLEnable

Modified Paths:
--------------
    CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/config.py
    CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/root.py

Added Paths:
-----------
    CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/test/test_config.py

Modified: CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/config.py
===================================================================
--- CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/config.py	2006-12-07 18:32:43 UTC (rev 743)
+++ CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/config.py	2006-12-07 18:40:30 UTC (rev 744)
@@ -49,7 +49,9 @@
     'ServerStatsFile': '/Library/CalendarServer/Documents/stats.plist',
     'UserQuotaBytes': 104857600,
     'Verbose': False,
-    'twistdLocation': '/usr/share/caldavd/bin/twistd'}
+    'twistdLocation': '/usr/share/caldavd/bin/twistd',
+    'SACLEnable': True,
+}
 
 globs = globals()
 globs.update(DEFAULTS.copy())

Modified: CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/root.py
===================================================================
--- CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/root.py	2006-12-07 18:32:43 UTC (rev 743)
+++ CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/root.py	2006-12-07 18:40:30 UTC (rev 744)
@@ -38,9 +38,9 @@
     def __init__(self, path, *args, **kwargs):
         super(RootResource, self).__init__(path, *args, **kwargs)
         
-        from twistedcaldav import caldavd
+        from twistedcaldav import config
 
-        if caldavd.CONFIG['SACLEnable'] and RootResource.CheckSACL:
+        if config.SACLEnable and RootResource.CheckSACL:
             self.useSacls = True
 
     def checkSacl(self, request):

Added: CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/test/test_config.py
===================================================================
--- CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/test/test_config.py	                        (rev 0)
+++ CalendarServer/branches/caldavd-twistd-plugin-2/twistedcaldav/test/test_config.py	2006-12-07 18:40:30 UTC (rev 744)
@@ -0,0 +1,62 @@
+##
+# Copyright (c) 2005-2006 Apple Computer, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# DRI: David Reid, dreid at apple.com
+##
+
+from twisted.trial import unittest
+
+from twistedcaldav import config
+
+testConfig = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+  <key>Verbose</key>
+  <true/>
+</dict>
+</plist>
+"""
+
+class ConfigTests(unittest.TestCase):
+    def setUp(self):
+        reload(config)
+        self.testConfig = self.mktemp()
+        open(self.testConfig, 'w').write(testConfig)
+
+    def testDefaults(self):
+        for key, value in config.DEFAULTS.iteritems():
+            self.failUnless(key in config.__dict__)
+            self.assertEquals(config.__dict__[key], value)
+
+    def testParseConfig(self):
+        self.assertEquals(config.Verbose, False)
+
+        config.parseConfig(self.testConfig)
+
+        self.assertEquals(config.Verbose, True)
+    
+    def testScoping(self):
+        def getVerbose():
+            from twistedcaldav import config
+            self.assertEquals(config.Verbose, True)
+
+        self.assertEquals(config.Verbose, False)
+
+        config.parseConfig(self.testConfig)
+
+        self.assertEquals(config.Verbose, True)
+
+        getVerbose()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061207/da6f6125/attachment.html


More information about the calendarserver-changes mailing list