[CalendarServer-changes] [11924] CalendarServer/trunk/twext/who/test/test_directory.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:18:42 PDT 2014


Revision: 11924
          http://trac.calendarserver.org//changeset/11924
Author:   wsanchez at apple.com
Date:     2013-11-08 16:28:53 -0800 (Fri, 08 Nov 2013)
Log Message:
-----------
Test repr.
Better test attribute access.

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

Modified: CalendarServer/trunk/twext/who/test/test_directory.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_directory.py	2013-11-08 23:59:33 UTC (rev 11923)
+++ CalendarServer/trunk/twext/who/test/test_directory.py	2013-11-09 00:28:53 UTC (rev 11924)
@@ -477,6 +477,12 @@
         FieldName.emailAddresses: (u"sagen at CalendarServer.org",)
     }
 
+    fields_nobody = {
+        FieldName.uid: u"UID:nobody",
+        FieldName.recordType: RecordType.user,
+        FieldName.shortNames: (u"nobody",),
+    }
+
     fields_staff = {
         FieldName.uid: u"UID:staff",
         FieldName.recordType: RecordType.group,
@@ -596,6 +602,18 @@
         )
 
 
+    def test_repr(self):
+        """
+        C{repr} returns the expected string.
+        """
+        wsanchez = self.makeRecord(self.fields_wsanchez)
+
+        self.assertEquals(
+            "<DirectoryRecord (user)wsanchez>",
+            repr(wsanchez)
+        )
+
+
     def test_compare(self):
         """
         Comparison of records.
@@ -640,7 +658,13 @@
             wsanchez.fields[FieldName.emailAddresses]
         )
 
+        self.assertRaises(AttributeError, lambda: wsanchez.fooBarBaz)
 
+        nobody = self.makeRecord(self.fields_nobody)
+
+        self.assertRaises(AttributeError, lambda: nobody.emailAddresses)
+
+
     @inlineCallbacks
     def test_members_group(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/9f865bf1/attachment.html>


More information about the calendarserver-changes mailing list