def setUpCalendarStore(test): test.root = FilePath(test.mktemp()) test.root.createDirectory() storeRootPath = test.storeRootPath = test.root.child("store") calendarPath = storeRootPath.child("calendars").child("__uids__") calendarPath.parent().makedirs() storePath.copyTo(calendarPath) # Set year values to current year nowYear = DateTime.getToday().getYear() for home in calendarPath.child("ho").child("me").children(): if not home.basename().startswith("."): for calendar in home.children(): if not calendar.basename().startswith("."): for resource in calendar.children(): if resource.basename().endswith(".ics"): resource.setContent(resource.getContent() % {"now": nowYear}) testID = test.id() test.calendarStore = CalendarStore( storeRootPath, {"push": test.notifierFactory} if test.notifierFactory else {}, buildDirectory(), quota=deriveQuota(test), ) test.txn = test.calendarStore.newTransaction(testID + "(old)") assert test.calendarStore is not None, "No calendar store?"
def setUpCalendarStore(test): test.root = FilePath(test.mktemp()) test.root.createDirectory() storeRootPath = test.storeRootPath = test.root.child("store") calendarPath = storeRootPath.child("calendars").child("__uids__") calendarPath.parent().makedirs() storePath.copyTo(calendarPath) # Set year values to current year nowYear = DateTime.getToday().getYear() for home in calendarPath.child("ho").child("me").children(): if not home.basename().startswith("."): for calendar in home.children(): if not calendar.basename().startswith("."): for resource in calendar.children(): if resource.basename().endswith(".ics"): resource.setContent(resource.getContent() % {"now": nowYear}) testID = test.id() test.counter = 0 test.notifierFactory = StubNotifierFactory() test.calendarStore = CalendarStore( storeRootPath, {"push": test.notifierFactory} if test.notifierFactory else {}, None, # must create directory later quota=deriveQuota(test), ) test.directory = buildTestDirectory(test.calendarStore, test.mktemp()) test.txn = test.calendarStore.newTransaction(testID + "(old)") assert test.calendarStore is not None, "No calendar store?"
def createDataStore(self): """ Create an L{IDataStore} that can store calendars (but not addressbooks.) By default returns a L{CommonDataStore}, but this is a hook for subclasses to override to provide different data stores. """ return CommonDataStore(FilePath(config.DocumentRoot), None, None, True, False, quota=deriveQuota(self))
def test_attachmentQuotaExceeded(self): """ Exceeding quota on an attachment returns an HTTP error code. """ self.patch(config, "EnableDropBox", True) if not hasattr(self._sqlCalendarStore, "_dropbox_ok"): self._sqlCalendarStore._dropbox_ok = False self.patch(self._sqlCalendarStore, "_dropbox_ok", True) self.patch(Calendar, "sharingInvites", lambda self: []) yield self.populateOneObject("1.ics", test_event_text) calendarObject = yield self.getResource( "/calendars/users/wsanchez/dropbox/uid-test.dropbox/too-big-attachment", "PUT", "wsanchez") self.requestUnderTest.stream = MemoryStream("x" * deriveQuota(self) * 2) try: result = yield calendarObject.http_PUT(self.requestUnderTest) except HTTPError, he: self.assertEquals(he.response.code, INSUFFICIENT_STORAGE_SPACE)
def test_attachmentQuotaExceeded(self): """ Exceeding quota on an attachment returns an HTTP error code. """ self.patch(config, "EnableDropBox", True) if not hasattr(self._sqlCalendarStore, "_dropbox_ok"): self._sqlCalendarStore._dropbox_ok = False self.patch(self._sqlCalendarStore, "_dropbox_ok", True) self.patch(Calendar, "sharingInvites", lambda self: []) yield self.populateOneObject("1.ics", test_event_text) calendarObject = yield self.getResource( "/calendars/users/wsanchez/dropbox/uid-test.dropbox/too-big-attachment", "PUT", "wsanchez" ) self.requestUnderTest.stream = MemoryStream( "x" * deriveQuota(self) * 2) try: result = yield calendarObject.http_PUT(self.requestUnderTest) except HTTPError, he: self.assertEquals(he.response.code, INSUFFICIENT_STORAGE_SPACE)
def setUpCalendarStore(test): test.root = FilePath(test.mktemp()) test.root.createDirectory() storeRootPath = test.storeRootPath = test.root.child("store") calendarPath = storeRootPath.child("calendars").child("__uids__") calendarPath.parent().makedirs() storePath.copyTo(calendarPath) # Set year values to current year subs = {} nowYear = DateTime.getToday().getYear() subs["now"] = nowYear for i in range(1, 10): subs["now-{}".format(i)] = nowYear - 1 subs["now+{}".format(i)] = nowYear + 1 for home in calendarPath.child("ho").child("me").children(): if not home.basename().startswith("."): for calendar in home.children(): if not calendar.basename().startswith("."): for resource in calendar.children(): if resource.basename().endswith(".ics"): resource.setContent(resource.getContent() % subs) testID = test.id() test.counter = 0 test.notifierFactory = StubNotifierFactory() test.calendarStore = CalendarStore( storeRootPath, {"push": test.notifierFactory} if test.notifierFactory else {}, None, # must create directory later quota=deriveQuota(test), ) test.directory = buildTestDirectory(test.calendarStore, test.mktemp()) test.txn = test.calendarStore.newTransaction(testID + "(old)") assert test.calendarStore is not None, "No calendar store?"