Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix test failure after recent attachment size limit changes.

  • Loading branch information
cyrusdaboo committed Apr 21, 2014
1 parent 1ffca53 commit 9ebcf9a02c850ad338f98a55a6c9ffe8bed2a0a7
Showing with 20 additions and 9 deletions.
  1. +20 −9 txdav/caldav/datastore/test/test_attachments.py
@@ -856,6 +856,11 @@ def setUp(self):
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,15 +1138,15 @@ def checkOriginal():


@inlineCallbacks
def exceedSizeTest(self, getit):
def exceedSizeTest(self, getit, name):
"""
If too many bytes are passed to the transport returned by
L{ICalendarObject.createAttachmentWithName},
L{IAttachmentStorageTransport.loseConnection} will return a L{Deferred}
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 @@ def test_exceedSizeNew(self):
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 @@ def test_exceedSizeReplace(self):
"""
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 @@ def populate(self):
Where=None
).on(txn)

cs = schema.CALENDARSERVER
yield Delete(
From=cs,
Where=cs.NAME == "MANAGED-ATTACHMENTS"
).on(txn)

yield txn.commit()


0 comments on commit 9ebcf9a

Please sign in to comment.
You can’t perform that action at this time.