[CalendarServer-changes] [11985] CalendarServer/trunk/twext/who/test
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:15:25 PDT 2014
Revision: 11985
http://trac.calendarserver.org//changeset/11985
Author: wsanchez at apple.com
Date: 2013-11-20 00:56:17 -0800 (Wed, 20 Nov 2013)
Log Message:
-----------
Add test_unIndexedRecordsFromMatchExpression_*
Modified Paths:
--------------
CalendarServer/trunk/twext/who/test/test_directory.py
CalendarServer/trunk/twext/who/test/test_index.py
Modified: CalendarServer/trunk/twext/who/test/test_directory.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_directory.py 2013-11-20 08:34:59 UTC (rev 11984)
+++ CalendarServer/trunk/twext/who/test/test_directory.py 2013-11-20 08:56:17 UTC (rev 11985)
@@ -841,7 +841,11 @@
"""
self.addUser(
shortNames=[u"wsanchez", u"wilfredo_sanchez"],
- fullNames=[u"Wilfredo S\xe1nchez Vega"],
+ fullNames=[
+ u"Wilfredo S\xe1nchez Vega",
+ u"Wilfredo Sanchez Vega",
+ u"Wilfredo Sanchez",
+ ],
emailAddresses=[
u"wsanchez at bitbucket.calendarserver.org",
u"wsanchez at devnull.twistedmatrix.com",
Modified: CalendarServer/trunk/twext/who/test/test_index.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_index.py 2013-11-20 08:34:59 UTC (rev 11984)
+++ CalendarServer/trunk/twext/who/test/test_index.py 2013-11-20 08:56:17 UTC (rev 11985)
@@ -220,15 +220,99 @@
self.assertFailure(result, NotImplementedError)
- def test_unIndexedRecordsFromMatchExpression(self):
+ @inlineCallbacks
+ def _test_unIndexedRecordsFromMatchExpression(
+ self,
+ inOut, matchType,
+ fieldName=BaseFieldName.fullNames,
+ ):
+ service = self.noLoadServicePopulated()
+
+ for subString, uids in (inOut):
+ records = yield service.unIndexedRecordsFromMatchExpression(
+ MatchExpression(
+ fieldName, subString,
+ matchType
+ )
+ )
+ self.assertEquals(
+ set((record.uid for record in records)),
+ set(uids)
+ )
+
+
+ def test_unIndexedRecordsFromMatchExpression_startsWith(self):
"""
- L{DirectoryService.unIndexedRecordsFromMatchExpression} ...
+ L{DirectoryService.unIndexedRecordsFromMatchExpression} with a
+ startsWith expression.
"""
- raise NotImplementedError()
+ return self._test_unIndexedRecordsFromMatchExpression(
+ (
+ (u"Wilfredo", (u"__wsanchez__",)), # Duplicates
+ (u"A", (u"__alyssa__", u"__dre__")), # Multiple
+ (u"Andre", (u"__dre__",)), # Single
+ ),
+ MatchType.startsWith
+ )
- test_unIndexedRecordsFromMatchExpression.todo = "Unimplemented"
+ def test_unIndexedRecordsFromMatchExpression_contains(self):
+ """
+ L{DirectoryService.unIndexedRecordsFromMatchExpression} with a contains
+ expression.
+ """
+ return self._test_unIndexedRecordsFromMatchExpression(
+ (
+ (u"Sanchez", (u"__wsanchez__",)), # Duplicates
+ (u"A", (u"__alyssa__", u"__dre__")), # Multiple
+ (u"LaBra", (u"__dre__",)), # Single
+ ),
+ MatchType.contains
+ )
+
+ def test_unIndexedRecordsFromMatchExpression_equals(self):
+ """
+ L{DirectoryService.unIndexedRecordsFromMatchExpression} with an equals
+ expression.
+ """
+ return self._test_unIndexedRecordsFromMatchExpression(
+ (
+ (u"Wilfredo Sanchez", (u"__wsanchez__",)), # MultiValue
+ (u"Andre LaBranche", (u"__dre__",)), # Single value
+ ),
+ MatchType.equals
+ )
+
+
+ def test_unIndexedRecordsFromMatchExpression_indexed(self):
+ """
+ L{DirectoryService.unIndexedRecordsFromMatchExpression} with an
+ indexed field name.
+ """
+ self._test_unIndexedRecordsFromMatchExpression(
+ (
+ (u"wsanchez", (u"__wsanchez__",)),
+ ),
+ MatchType.equals,
+ fieldName=BaseFieldName.shortNames
+ )
+
+
+ def test_unIndexedRecordsFromMatchExpression_notMatchExpression(self):
+ """
+ L{DirectoryService.unIndexedRecordsFromMatchExpression} with a
+ non-match expression.
+ """
+ result = self._test_unIndexedRecordsFromMatchExpression(
+ (
+ (u"zehcnasw", (u"__wsanchez__",)),
+ ),
+ "Not a match type we know about"
+ )
+ self.assertFailure(result, NotImplementedError)
+
+
def test_recordsFromNonCompoundExpression(self):
"""
L{DirectoryService.recordsFromNonCompoundExpression} ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/a83818cd/attachment.html>
More information about the calendarserver-changes
mailing list