[CalendarServer-changes] [11918] CalendarServer/trunk/twext/who/test/test_directory.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:17:02 PDT 2014
Revision: 11918
http://trac.calendarserver.org//changeset/11918
Author: wsanchez at apple.com
Date: 2013-11-08 14:12:54 -0800 (Fri, 08 Nov 2013)
Log Message:
-----------
Add test_recordsFromNonCompoundExpression_nonEmptyRecords.
Add StubDirectoryService.
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 21:59:31 UTC (rev 11917)
+++ CalendarServer/trunk/twext/who/test/test_directory.py 2013-11-08 22:12:54 UTC (rev 11918)
@@ -74,7 +74,7 @@
def test_repr(self):
"""
- C{repr()} returns the expected string.
+ C{repr} returns the expected string.
"""
service = self.service()
self.assertEquals(repr(service), "<DirectoryService u'xyzzy'>")
@@ -120,6 +120,30 @@
self.assertEquals(set(result), set(()))
+ def test_recordsFromNonCompoundExpression_nonEmptyRecords(self):
+ """
+ C{recordsFromNonCompoundExpression} with an unknown expression type
+ and a non-empty C{records} fails with L{QueryNotSupportedError}.
+ """
+ service = self.service()
+
+ wsanchez = DirectoryRecord(
+ service,
+ {
+ service.fieldName.recordType: service.recordType.user,
+ service.fieldName.uid: u"__wsanchez__",
+ service.fieldName.shortNames: [u"wsanchez"],
+ }
+ )
+
+ self.assertFailure(
+ service.recordsFromNonCompoundExpression(
+ object(), records=((wsanchez,))
+ ),
+ QueryNotSupportedError
+ )
+
+
def test_recordsFromExpression_unknownExpression(self):
"""
C{recordsFromExpression} with an unknown expression type fails with
@@ -434,3 +458,106 @@
def test_groups(self):
wsanchez = self.makeRecord(self.fields_wsanchez)
self.assertFailure(wsanchez.groups(), NotImplementedError)
+
+
+
+class StubDirectoryService(DirectoryService):
+ def __init__(self):
+ DirectoryService.__init__(self, self.realmName)
+
+ self.records = []
+ self._addRecords()
+
+
+ def _addRecords(self):
+ self._addUser(
+ shortNames=[u"wsanchez", u"wilfredo_sanchez"],
+ fullNames=[u"Wilfredo S\xe1nchez Vega"],
+ emailAddresses=[
+ u"wsanchez at bitbucket.calendarserver.org",
+ u"wsanchez at devnull.twistedmatrix.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"glyph"],
+ fullNames=[u"Glyph Lefkowitz"],
+ emailAddresses=[
+ u"glyph at bitbucket.calendarserver.org",
+ u"glyph at devnull.twistedmatrix.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"sagen"],
+ fullNames=[u"Morgen Sagen"],
+ emailAddresses=[
+ u"sagen at bitbucket.calendarserver.org",
+ u"shared at example.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"cdaboo"],
+ fullNames=[u"Cyrus Daboo"],
+ emailAddresses=[
+ u"cdaboo at bitbucket.calendarserver.org",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"dre"],
+ fullNames=[u"Andre LaBranche"],
+ emailAddresses=[
+ u"dre at bitbucket.calendarserver.org",
+ u"shared at example.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"exarkun"],
+ fullNames=[u"Jean-Paul Calderone"],
+ emailAddresses=[
+ u"exarkun at devnull.twistedmatrix.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"dreid"],
+ fullNames=[u"David Reid"],
+ emailAddresses=[
+ u"dreid at devnull.twistedmatrix.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"joe"],
+ fullNames=[u"Joe Schmoe"],
+ emailAddresses=[
+ u"joe at example.com",
+ ],
+ )
+
+ self._addUser(
+ shortNames=[u"alyssa"],
+ fullNames=[u"Alyssa P. Hacker"],
+ emailAddresses=[
+ u"alyssa at example.com",
+ ],
+ )
+
+
+ def _addUser(self, shortNames, fullNames, emailAddresses=[]):
+ self.records.append(DirectoryRecord(self, {
+ self.fieldName.recordType: self.recordType.user,
+ self.fieldName.uid: u"__{0}__".format(shortNames[0]),
+ self.fieldName.shortNames: shortNames,
+ self.fieldName.fullNames: fullNames,
+ self.fieldName.password: u"".join(reversed(shortNames[0])),
+ self.fieldName.emailAddresses: emailAddresses,
+ }))
+
+
+ def recordsFromNonCompoundExpression(expression, records=None):
+ if expression == "":
+ pass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/33d3fbe4/attachment.html>
More information about the calendarserver-changes
mailing list