[CalendarServer-changes] [11964] CalendarServer/trunk/twext/who
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:24:04 PDT 2014
Revision: 11964
http://trac.calendarserver.org//changeset/11964
Author: wsanchez at apple.com
Date: 2013-11-18 17:56:11 -0800 (Mon, 18 Nov 2013)
Log Message:
-----------
Test structure cleanup
Modified Paths:
--------------
CalendarServer/trunk/twext/who/index.py
CalendarServer/trunk/twext/who/test/test_directory.py
CalendarServer/trunk/twext/who/test/test_index.py
CalendarServer/trunk/twext/who/test/test_xml.py
Modified: CalendarServer/trunk/twext/who/index.py
===================================================================
--- CalendarServer/trunk/twext/who/index.py 2013-11-18 21:59:19 UTC (rev 11963)
+++ CalendarServer/trunk/twext/who/index.py 2013-11-19 01:56:11 UTC (rev 11964)
@@ -130,10 +130,10 @@
<FieldName=memberUIDs>: {
u'__sagen__': set([<DirectoryRecord (group)calendar-dev>]),
u'__wsanchez__': set([<DirectoryRecord (group)calendar-dev>])
- },
+ }
}
- The field names that are indexed are determined by the C{indexedFields}
+ The field names that are indexed are defined by the C{indexedFields}
attribute of the service.
A subclass must override L{loadRecords}, which populates the index.
@@ -187,7 +187,8 @@
"""
Load records. This must be implemented by subclasses.
- The implementation should set the index with current data.
+ The implementation should set the index property with current index
+ data.
"""
raise NotImplementedError("Subclasses must implement loadRecords().")
Modified: CalendarServer/trunk/twext/who/test/test_directory.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_directory.py 2013-11-18 21:59:19 UTC (rev 11963)
+++ CalendarServer/trunk/twext/who/test/test_directory.py 2013-11-19 01:56:11 UTC (rev 11964)
@@ -25,7 +25,6 @@
from twisted.python.constants import Names, NamedConstant
from twisted.trial import unittest
-from twisted.trial.unittest import SkipTest
from twisted.internet.defer import inlineCallbacks
from twisted.internet.defer import succeed
@@ -46,7 +45,7 @@
def service(self):
if not hasattr(self, "_service"):
- self._service = DirectoryService(self.realmName)
+ self._service = self.serviceClass(self.realmName)
return self._service
@@ -55,7 +54,10 @@
"""
Tests for directory services.
"""
+ serviceClass = DirectoryService
+ directoryRecordClass = DirectoryRecord
+
def test_interface(self):
"""
Service instance conforms to L{IDirectoryService}.
@@ -130,7 +132,7 @@
"""
service = self.service()
- wsanchez = DirectoryRecord(
+ wsanchez = self.directoryRecordClass(
service,
{
service.fieldName.recordType: service.recordType.user,
@@ -403,14 +405,17 @@
"""
Tests for immutable directory services.
"""
+ serviceClass = DirectoryService
+ directoryRecordClass = DirectoryRecord
+
def test_updateRecordsNotAllowed(self):
"""
Updating records is not allowed.
"""
service = self.service()
- newRecord = DirectoryRecord(
+ newRecord = self.directoryRecordClass(
service,
fields={
service.fieldName.uid: u"__plugh__",
@@ -451,7 +456,10 @@
"""
Tests for directory records.
"""
+ serviceClass = DirectoryService
+ directoryRecordClass = DirectoryRecord
+
fields_wsanchez = {
FieldName.uid: u"UID:wsanchez",
FieldName.recordType: RecordType.user,
@@ -695,15 +703,15 @@
def test_members_group(self):
"""
- Group members.
+ Group members for group records.
"""
- raise SkipTest("Subclasses should implement this test.")
+ raise NotImplementedError("Subclasses should implement this test.")
@inlineCallbacks
def test_members_nonGroup(self):
"""
- Non-groups have no members.
+ Group members for non-group records. Non-groups have no members.
"""
wsanchez = self.makeRecord(self.fields_wsanchez)
@@ -713,11 +721,11 @@
)
- def test_groups(self):
+ def test_memberships(self):
"""
Group memberships.
"""
- raise SkipTest("Subclasses should implement this test.")
+ raise NotImplementedError("Subclasses should implement this test.")
@@ -728,7 +736,7 @@
self.assertFailure(staff.members(), NotImplementedError)
- def test_groups(self):
+ def test_memberships(self):
wsanchez = self.makeRecord(self.fields_wsanchez)
self.assertFailure(wsanchez.groups(), NotImplementedError)
Modified: CalendarServer/trunk/twext/who/test/test_index.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_index.py 2013-11-18 21:59:19 UTC (rev 11963)
+++ CalendarServer/trunk/twext/who/test/test_index.py 2013-11-19 01:56:11 UTC (rev 11964)
@@ -20,6 +20,8 @@
from twisted.trial import unittest
+from twext.who.directory import DirectoryService, DirectoryRecord
+
from twext.who.test import test_directory
@@ -28,15 +30,20 @@
"""
Tests for indexed directory services.
"""
+ serviceClass = DirectoryService
+ directoryRecordClass = DirectoryRecord
class DirectoryServiceTest(unittest.TestCase, BaseDirectoryServiceTest):
def _noop(self):
"""
- Does nothing.
+ Does nothing for this class.
"""
+ if self.__class__ is not DirectoryServiceTest:
+ raise NotImplementedError("Subclasses should implement this test.")
+
test_recordWithUID = _noop
test_recordWithGUID = _noop
test_recordsWithRecordType = _noop
@@ -51,6 +58,8 @@
"""
Tests for immutable indexed directory services.
"""
+ serviceClass = DirectoryService
+ directoryRecordClass = DirectoryRecord
@@ -65,8 +74,19 @@
"""
Tests for indexed directory records.
"""
+ serviceClass = DirectoryService
+ directoryRecordClass = DirectoryRecord
class DirectoryRecordTest(unittest.TestCase, BaseDirectoryRecordTest):
- pass
+ def _noop(self):
+ """
+ Does nothing for this class.
+ """
+ if self.__class__ is not DirectoryRecordTest:
+ raise NotImplementedError("Subclasses should implement this test.")
+
+
+ test_members_group = _noop
+ test_memberships = _noop
Modified: CalendarServer/trunk/twext/who/test/test_xml.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_xml.py 2013-11-18 21:59:19 UTC (rev 11963)
+++ CalendarServer/trunk/twext/who/test/test_xml.py 2013-11-19 01:56:11 UTC (rev 11964)
@@ -699,7 +699,7 @@
newRecord = DirectoryRecord(
service,
fields={
- service.fieldName.uid: u"__plugh__",
+ service.fieldName.uid: u"__plugh__",
service.fieldName.recordType: service.recordType.user,
service.fieldName.shortNames: (u"plugh",),
}
@@ -723,7 +723,7 @@
newRecord = DirectoryRecord(
service,
fields={
- service.fieldName.uid: u"__plugh__",
+ service.fieldName.uid: u"__plugh__",
service.fieldName.recordType: service.recordType.user,
service.fieldName.shortNames: (u"plugh",),
}
@@ -758,7 +758,7 @@
class DirectoryRecordTest(BaseTest, test_index.BaseDirectoryRecordTest):
@inlineCallbacks
- def test_members(self):
+ def test_members_group(self):
service = self.service()
record = (yield service.recordWithUID(u"__wsanchez__"))
@@ -790,7 +790,7 @@
)
@inlineCallbacks
- def test_groups(self):
+ def test_memberships(self):
service = self.service()
record = (yield service.recordWithUID(u"__wsanchez__"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/a7927d61/attachment.html>
More information about the calendarserver-changes
mailing list