[CalendarServer-changes] [13345] CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments. py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 21 10:03:59 PDT 2014
Revision: 13345
http://trac.calendarserver.org//changeset/13345
Author: cdaboo at apple.com
Date: 2014-04-21 10:03:59 -0700 (Mon, 21 Apr 2014)
Log Message:
-----------
Fix test failure after recent attachment size limit changes.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py 2014-04-21 16:18:28 UTC (rev 13344)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py 2014-04-21 17:03:59 UTC (rev 13345)
@@ -856,7 +856,12 @@
self.patch(config, "EnableManagedAttachments", True)
self._sqlCalendarStore.enableManagedAttachments = True
+ # Make it look like we have migrated
+ if (yield self.transactionUnderTest().calendarserverValue("MANAGED-ATTACHMENTS", raiseIfMissing=False)) is None:
+ yield self.transactionUnderTest().setCalendarserverValue("MANAGED-ATTACHMENTS", "1")
+ yield self.commit()
+
@inlineCallbacks
def createAttachmentTest(self, refresh):
"""
@@ -1133,7 +1138,7 @@
@inlineCallbacks
- def exceedSizeTest(self, getit):
+ def exceedSizeTest(self, getit, name):
"""
If too many bytes are passed to the transport returned by
L{ICalendarObject.createAttachmentWithName},
@@ -1141,7 +1146,7 @@
that fails with L{AttachmentSizeTooLarge}.
"""
attachment = yield getit()
- t = attachment.store(MimeType("text", "x-fixture"), "")
+ t = attachment.store(MimeType("text", "x-fixture"), name)
sample = "all work and no play makes jack a dull boy"
chunk = (sample * (config.MaximumAttachmentSize / len(sample)))
@@ -1161,12 +1166,12 @@
self.patch(config, "MaximumAttachmentSize", 100)
obj = yield self.calendarObjectUnderTest()
yield self.exceedSizeTest(
- lambda: obj.createAttachmentWithName("too-big.attachment")
+ lambda: obj.createManagedAttachment(), "too-big.attachment"
)
- self.assertEquals((yield obj.attachments()), [])
+ self.assertEquals((yield obj.managedAttachmentList()), [])
yield self.commit()
obj = yield self.calendarObjectUnderTest()
- self.assertEquals((yield obj.attachments()), [])
+ self.assertEquals((yield obj.managedAttachmentList()), [])
@inlineCallbacks
@@ -1177,14 +1182,14 @@
"""
self.patch(config, "MaximumAttachmentSize", 100)
obj = yield self.calendarObjectUnderTest()
- create = lambda: obj.createAttachmentWithName("exists.attachment")
- get = lambda: obj.attachmentWithName("exists.attachment")
+ create = lambda: obj.createManagedAttachment()
attachment = yield create()
- t = attachment.store(MimeType("text", "x-fixture"), "")
+ get = lambda: obj.attachmentWithManagedID(attachment.managedID())
+ t = attachment.store(MimeType("text", "x-fixture"), "new.attachment")
sampleData = "a reasonably sized attachment"
t.write(sampleData)
yield t.loseConnection()
- yield self.exceedSizeTest(get)
+ yield self.exceedSizeTest(get, "exists.attachment")
@inlineCallbacks
def checkOriginal():
actual = yield self.attachmentToString(attachment)
@@ -1563,6 +1568,12 @@
Where=None
).on(txn)
+ cs = schema.CALENDARSERVER
+ yield Delete(
+ From=cs,
+ Where=cs.NAME == "MANAGED-ATTACHMENTS"
+ ).on(txn)
+
yield txn.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140421/3a7d924c/attachment.html>
More information about the calendarserver-changes
mailing list