[CalendarServer-changes] [13420] twext/trunk/twext/who
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 2 19:31:24 PDT 2014
Revision: 13420
http://trac.calendarserver.org//changeset/13420
Author: wsanchez at apple.com
Date: 2014-05-02 19:31:24 -0700 (Fri, 02 May 2014)
Log Message:
-----------
raise DirectoryAvailabilityError() if the XML file is missing.
Modified Paths:
--------------
twext/trunk/twext/who/test/test_xml.py
twext/trunk/twext/who/xml.py
Modified: twext/trunk/twext/who/test/test_xml.py
===================================================================
--- twext/trunk/twext/who/test/test_xml.py 2014-05-03 02:17:35 UTC (rev 13419)
+++ twext/trunk/twext/who/test/test_xml.py 2014-05-03 02:31:24 UTC (rev 13420)
@@ -27,7 +27,7 @@
from twisted.python.filepath import FilePath
from twisted.internet.defer import inlineCallbacks
-from ..idirectory import NoSuchRecordError
+from ..idirectory import DirectoryAvailabilityError, NoSuchRecordError
from ..expression import (
CompoundExpression, Operand,
MatchExpression, MatchType, MatchFlags
@@ -888,26 +888,19 @@
)
+
class MissingFileTest(unittest.TestCase):
- @inlineCallbacks
def test_missingFile(self):
service = DirectoryService(FilePath(self.mktemp()))
- record = yield service.recordWithUID(u"missing")
- self.assertEquals(record, None)
- fields = {
- service.fieldName.uid: u"notmissing",
- service.fieldName.recordType: service.recordType.user,
- }
+ self.assertFailure(
+ service.recordWithUID(u"missing"),
+ DirectoryAvailabilityError
+ )
- updatedRecord = DirectoryRecord(service, fields)
- yield service.updateRecords((updatedRecord,))
- record = yield service.recordWithUID(u"notmissing")
- self.assertEquals(record.uid, u"notmissing")
-
class QueryMixIn(object):
def query(
self,
Modified: twext/trunk/twext/who/xml.py
===================================================================
--- twext/trunk/twext/who/xml.py 2014-05-03 02:17:35 UTC (rev 13419)
+++ twext/trunk/twext/who/xml.py 2014-05-03 02:31:24 UTC (rev 13420)
@@ -39,7 +39,7 @@
from twisted.internet.defer import fail
from .idirectory import (
- DirectoryServiceError,
+ DirectoryServiceError, DirectoryAvailabilityError,
NoSuchRecordError, UnknownRecordTypeError,
RecordType as BaseRecordType, FieldName as BaseFieldName,
)
@@ -211,8 +211,7 @@
Does nothing if a successful refresh has happened within the
last L{self.refreshInterval} seconds.
- @param loadNow: If true, load now (ignoring
- L{self.refreshInterval})
+ @param loadNow: If true, load now (ignoring L{self.refreshInterval})
@type loadNow: L{type}
@param stat: If true, check file metadata and don't reload if
@@ -235,7 +234,9 @@
except (OSError, IOError):
# Can't read the file
self.flush()
- return
+ raise DirectoryAvailabilityError(
+ "Can't open {}".format(self.filePath)
+ )
cacheTag = (
self.filePath.getModificationTime(),
@@ -258,7 +259,9 @@
except (OSError, IOError):
# Can't read the file
self.flush()
- return
+ raise DirectoryAvailabilityError(
+ "Can't open {}".format(self.filePath)
+ )
#
# Pull data from DOM
@@ -545,7 +548,7 @@
Drop cached data and load the XML DOM.
"""
self.flush()
- etree = self.loadRecords(loadNow=True)
+ etree = self.loadRecords(loadNow=True, stat=False)
return etree.getroot()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140502/22b6df36/attachment-0001.html>
More information about the calendarserver-changes
mailing list