[CalendarServer-changes] [12755] twext/trunk/twext/who

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 26 13:17:32 PST 2014


Revision: 12755
          http://trac.calendarserver.org//changeset/12755
Author:   sagen at apple.com
Date:     2014-02-26 13:17:32 -0800 (Wed, 26 Feb 2014)
Log Message:
-----------
None is a legal value

Modified Paths:
--------------
    twext/trunk/twext/who/directory.py
    twext/trunk/twext/who/test/test_directory.py

Modified: twext/trunk/twext/who/directory.py
===================================================================
--- twext/trunk/twext/who/directory.py	2014-02-26 02:23:34 UTC (rev 12754)
+++ twext/trunk/twext/who/directory.py	2014-02-26 21:17:32 UTC (rev 12755)
@@ -365,7 +365,7 @@
             elif issubclass(expectedType, Names):
                 expectedType = NamedConstant
 
-            if not isinstance(value, expectedType):
+            if value is not None and not isinstance(value, expectedType):
                 raise InvalidDirectoryRecordError(
                     "Value {0!r} for field {1} is not of type {2}".format(
                         value, name, expectedType

Modified: twext/trunk/twext/who/test/test_directory.py
===================================================================
--- twext/trunk/twext/who/test/test_directory.py	2014-02-26 02:23:34 UTC (rev 12754)
+++ twext/trunk/twext/who/test/test_directory.py	2014-02-26 21:17:32 UTC (rev 12755)
@@ -588,6 +588,13 @@
         FieldName.shortNames: (u"nobody",),
     }
 
+    fields_none_password = {
+        FieldName.uid: u"UID:nobody",
+        FieldName.recordType: RecordType.user,
+        FieldName.shortNames: (u"nobody",),
+        FieldName.password: None,
+    }
+
     fields_staff = {
         FieldName.uid: u"UID:staff",
         FieldName.recordType: RecordType.group,
@@ -732,6 +739,16 @@
         )
 
 
+    def test_noneIsAllowed(self):
+        """
+        Verify a value of None is allowed
+        """
+        service  = self.service()
+        record = self.makeRecord(self.fields_none_password, service=service)
+
+        self.assertEquals(record.password, None)
+
+
     def _test_containerClassFieldType(self, callback):
         """
         Scaffold for test_initWithContainerClassFieldType_*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140226/c578faba/attachment.html>


More information about the calendarserver-changes mailing list