[CalendarServer-changes] [11097] CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/ datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Apr 24 13:53:26 PDT 2013
Revision: 11097
http://trac.calendarserver.org//changeset/11097
Author: cdaboo at apple.com
Date: 2013-04-24 13:53:25 -0700 (Wed, 24 Apr 2013)
Log Message:
-----------
Checkpoint: iMIP + some test clean-up.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/schedule.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/delivery.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/inbound.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/scheduler.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_icaldiff.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_itip.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_pocessing.py
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_utils.py
Removed Paths:
-------------
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/accounts.xml
CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/resources.xml
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/schedule.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/schedule.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/schedule.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -182,6 +182,7 @@
def _createCalendarObjectWithNameInternal(self, name, component, internal_state, options=None):
return self.createCalendarObjectWithName(name, component, options)
+
def setSupportedComponents(self, supported_components):
"""
Update the database column with the supported components. Technically this should only happen once
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/delivery.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/delivery.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/delivery.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -26,7 +26,6 @@
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.python.failure import Failure
from twistedcaldav.caldavxml import caldav_namespace
-from twistedcaldav.directory.util import transactionFromRequest
from txdav.caldav.datastore.scheduling.delivery import DeliveryService
from txdav.caldav.datastore.scheduling.imip.outbound import IMIPInvitationWork
from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
@@ -100,7 +99,7 @@
fromAddr = str(self.scheduler.originator.cuaddr)
- txn = transactionFromRequest(self.scheduler.request, self.scheduler.request._newStoreTransaction.store)
+ txn = yield self.scheduler.txn.store().newTransaction("Submitting iMIP message for UID: %s" % (self.scheduler.calendar.resourceUID(),))
log.debug("Submitting iMIP message... To: '%s', From :'%s'\n%s" % (toAddr, fromAddr, caldata,))
yield txn.enqueue(IMIPInvitationWork, fromAddr=fromAddr, toAddr=toAddr, icalendarText=caldata)
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/inbound.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/inbound.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/inbound.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -17,27 +17,31 @@
"""
Inbound IMIP mail handling for Calendar Server
"""
-import datetime
-from calendarserver.tap.util import FakeRequest
-import email.utils
+
from twext.enterprise.dal.record import fromTable
from twext.enterprise.dal.syntax import Delete
from twext.enterprise.queue import WorkItem
+from twext.internet.gaiendpoint import GAIEndpoint
from twext.python.log import Logger, LoggingMixIn
+
from twisted.application import service
from twisted.internet import protocol, defer, ssl
from twisted.internet.defer import inlineCallbacks, returnValue, succeed
from twisted.mail import pop3client, imap4
from twisted.mail.smtp import messageid
+
from twistedcaldav.config import config
from twistedcaldav.ical import Property, Component
+
from txdav.caldav.datastore.scheduling.imip.scheduler import IMIPScheduler
from txdav.caldav.datastore.scheduling.imip.smtpsender import SMTPSender
from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
from txdav.common.datastore.sql_tables import schema
-from twext.internet.gaiendpoint import GAIEndpoint
+import datetime
+import email.utils
+
log = Logger()
#
@@ -72,10 +76,8 @@
@inlineCallbacks
def doWork(self):
- rootResource = self.transaction._rootResource
calendar = Component.fromString(self.icalendarText)
- yield injectMessage(self.transaction, rootResource, self.organizer, self.attendee,
- calendar)
+ yield injectMessage(self.transaction, self.organizer, self.attendee, calendar)
@@ -389,19 +391,12 @@
@inlineCallbacks
-def injectMessage(txn, root, organizer, attendee, calendar):
+def injectMessage(txn, organizer, attendee, calendar):
- request = FakeRequest(root, None, "/", transaction=txn)
- resource = root.getChild("principals")
- scheduler = IMIPScheduler(request, resource)
- scheduler.originator = attendee
- scheduler.recipients = [organizer, ]
- scheduler.calendar = calendar
-
try:
- results = (yield scheduler.doScheduling())
- log.info("Successfully injected iMIP response from %s to %s" %
- (attendee, organizer))
+ scheduler = IMIPScheduler(txn, None)
+ results = (yield scheduler.doSchedulingDirectly("iMIP", attendee, [organizer, ], calendar,))
+ log.info("Successfully injected iMIP response from %s to %s" % (attendee, organizer))
except Exception, e:
log.error("Failed to inject iMIP response (%s)" % (e,))
raise
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -15,7 +15,10 @@
##
from twext.web2 import responsecode
+
from twisted.internet.defer import inlineCallbacks
+from twisted.trial import unittest
+
from twistedcaldav.config import config
from twistedcaldav.ical import Component
@@ -24,9 +27,7 @@
from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
from txdav.caldav.datastore.scheduling.scheduler import ScheduleResponseQueue
-import twistedcaldav.test.util
-
-class iMIPProcessing (twistedcaldav.test.util.TestCase):
+class iMIPProcessing (unittest.TestCase):
"""
iCalendar support tests
"""
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -15,15 +15,11 @@
##
-from calendarserver.tap.util import getRootResource, directoryFromConfig
-
from twisted.internet.defer import inlineCallbacks
from twisted.python.modules import getModule
-from twistedcaldav.config import config, ConfigDict
+from twistedcaldav.config import ConfigDict
from twistedcaldav.ical import Component
-from twistedcaldav.test.util import TestCase
-from twistedcaldav.test.util import xmlFile
from txdav.caldav.datastore.scheduling.imip.inbound import IMIPReplyWork
from txdav.caldav.datastore.scheduling.imip.inbound import MailReceiver
@@ -33,17 +29,16 @@
from txdav.caldav.datastore.test.util import buildCalendarStore
import email
+from twisted.trial import unittest
-class InboundTests(TestCase):
+class InboundTests(unittest.TestCase):
@inlineCallbacks
def setUp(self):
super(InboundTests, self).setUp()
- self.patch(config.DirectoryService.params, "xmlFile", xmlFile)
- self.store = yield buildCalendarStore(self, None, directoryFromConfig(config))
- self.root = getRootResource(config, self.store)
+ self.store = yield buildCalendarStore(self, None)
self.directory = self.store.directoryService()
self.receiver = MailReceiver(self.store, self.directory)
self.retriever = MailRetriever(self.store, self.directory,
@@ -56,7 +51,6 @@
)
def decorateTransaction(txn):
- txn._rootResource = self.root
txn._mailRetriever = self.retriever
self.store.callWithNewTransactions(decorateTransaction)
@@ -295,7 +289,6 @@
txn = self.store.newTransaction()
result = (yield injectMessage(
txn,
- self.root,
"urn:uuid:user01",
"mailto:xyzzy at example.com",
calendar
@@ -329,7 +322,6 @@
txn = self.store.newTransaction()
result = (yield injectMessage(
txn,
- self.root,
"urn:uuid:unknown_user",
"mailto:xyzzy at example.com",
calendar
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -14,28 +14,24 @@
# limitations under the License.
##
-import os
-
from twisted.internet.defer import inlineCallbacks
-from twistedcaldav.test.util import TestCase
-from twistedcaldav.test.util import xmlFile
-from txdav.common.datastore.test.util import buildStore
-from calendarserver.tap.util import getRootResource
-from twistedcaldav.config import config
+from twisted.trial import unittest
+
from txdav.caldav.datastore.scheduling.imip.mailgateway import MailGatewayTokensDatabase
from txdav.caldav.datastore.scheduling.imip.mailgateway import migrateTokensToStore
+from txdav.common.datastore.test.util import buildStore
+import os
-class MailGatewayTokenDBTests(TestCase):
+class MailGatewayTokenDBTests(unittest.TestCase):
+
@inlineCallbacks
def setUp(self):
super(MailGatewayTokenDBTests, self).setUp()
self.store = yield buildStore(self, None)
- self.patch(config.DirectoryService.params, "xmlFile", xmlFile)
- self.root = getRootResource(config, self.store)
- self.directory = self.root.getDirectory()
+ self.directory = self.store.directoryService()
@inlineCallbacks
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -16,22 +16,25 @@
from __future__ import print_function
from cStringIO import StringIO
-import os
-import email
from pycalendar.datetime import PyCalendarDateTime
+
from twisted.internet.defer import inlineCallbacks, succeed
+from twisted.trial import unittest
from twisted.web.template import Element, renderer, flattenString
+
from twistedcaldav.config import config
-from twistedcaldav.directory import augment
-from twistedcaldav.directory.xmlfile import XMLDirectoryService
from twistedcaldav.ical import Component
+
from txdav.caldav.datastore.scheduling.imip.outbound import IMIPInvitationWork
from txdav.caldav.datastore.scheduling.imip.outbound import MailSender
from txdav.caldav.datastore.scheduling.imip.outbound import StringFormatTemplateLoader
-from twistedcaldav.test.util import TestCase, xmlFile, augmentsFile
from txdav.common.datastore.test.util import buildStore
+import email
+import os
+
+
initialInviteText = u"""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
@@ -84,18 +87,12 @@
-class OutboundTests(TestCase):
+class OutboundTests(unittest.TestCase):
@inlineCallbacks
def setUp(self):
self.store = yield buildStore(self, None)
- self.directory = XMLDirectoryService(
- {
- 'xmlFile' : xmlFile,
- 'augmentService' :
- augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,)),
- }
- )
+ self.directory = self.store.directoryService()
self.sender = MailSender("server at example.com", 7, DummySMTPSender(),
language="en")
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/scheduler.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/scheduler.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -597,7 +597,7 @@
results = []
for recipient in self.recipients:
# Get the principal resource for this recipient
- principal = self.txn.directoryService.recordWithCalendarUserAddress(recipient)
+ principal = self.txn.directoryService().recordWithCalendarUserAddress(recipient)
# If no principal we may have a remote recipient but we should check whether
# the address is one that ought to be on our server and treat that as a missing
Deleted: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/accounts.xml
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/accounts.xml 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/accounts.xml 2013-04-24 20:53:25 UTC (rev 11097)
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-Copyright (c) 2013 Apple Inc. All rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- -->
-
-<!DOCTYPE accounts SYSTEM "../../../conf/auth/accounts.dtd">
-
-<accounts realm="Test">
- <user repeat="99">
- <uid>user%02d</uid>
- <uid>User %02d</uid>
- <guid>user%02d</guid>
- <password>user%02d</password>
- <name>User %02d</name>
- <first-name>User</first-name>
- <last-name>%02d</last-name>
- <email-address>user%02d at example.com</email-address>
- </user>
-</accounts>
Deleted: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/resources.xml
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/resources.xml 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/resources.xml 2013-04-24 20:53:25 UTC (rev 11097)
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<accounts realm="/Search">
-</accounts>
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_icaldiff.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_icaldiff.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_icaldiff.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -16,9 +16,10 @@
from difflib import unified_diff
-from twistedcaldav.config import config
+from twisted.trial import unittest
+
+from twistedcaldav.stdconfig import config
from twistedcaldav.ical import Component
-import twistedcaldav.test.util
from txdav.caldav.datastore.scheduling.icaldiff import iCalDiff
@@ -26,7 +27,7 @@
import re
-class ICalDiff (twistedcaldav.test.util.TestCase):
+class ICalDiff (unittest.TestCase):
"""
iCalendar support tests
"""
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_itip.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_itip.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_itip.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -18,15 +18,16 @@
from pycalendar.datetime import PyCalendarDateTime
from pycalendar.timezone import PyCalendarTimezone
+from twisted.trial import unittest
+
from twistedcaldav.ical import Component
from txdav.caldav.datastore.scheduling.itip import iTipProcessing, iTipGenerator
import os
-import twistedcaldav.test.util
-class iTIPProcessing (twistedcaldav.test.util.TestCase):
+class iTIPProcessing (unittest.TestCase):
"""
iCalendar support tests
"""
@@ -1605,7 +1606,7 @@
-class iTIPGenerator (twistedcaldav.test.util.TestCase):
+class iTIPGenerator (unittest.TestCase):
"""
iCalendar support tests
"""
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_pocessing.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_pocessing.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_pocessing.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -15,13 +15,14 @@
##
from twisted.internet.defer import inlineCallbacks
+from twisted.trial import unittest
-from twistedcaldav.config import config
+from twistedcaldav import memcacher
from twistedcaldav.ical import Component
+from twistedcaldav.stdconfig import config
from txdav.caldav.datastore.scheduling.processing import ImplicitProcessor
-import twistedcaldav.test.util
class FakeImplicitProcessor(ImplicitProcessor):
"""
@@ -48,11 +49,19 @@
-class BatchRefresh (twistedcaldav.test.util.TestCase):
+class BatchRefresh (unittest.TestCase):
"""
iCalendar support tests
"""
+ def setUp(self):
+ super(BatchRefresh, self).setUp()
+ config.Memcached.Pools.Default.ClientEnabled = False
+ config.Memcached.Pools.Default.ServerEnabled = False
+ memcacher.Memcacher.allowTestCache = True
+ memcacher.Memcacher.memoryCacheInstance = None
+
+
@inlineCallbacks
def test_queueAttendeeUpdate_no_refresh(self):
Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_utils.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_utils.py 2013-04-24 18:58:18 UTC (rev 11096)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/test/test_utils.py 2013-04-24 20:53:25 UTC (rev 11097)
@@ -18,23 +18,17 @@
Tests for calendarserver.tools.purge
"""
-from calendarserver.tap.util import getRootResource, directoryFromConfig
-
from pycalendar.datetime import PyCalendarDateTime
from twisted.internet.defer import inlineCallbacks
from twisted.trial import unittest
-from twistedcaldav.config import config
-
from txdav.caldav.datastore.scheduling.utils import getCalendarObjectForRecord
from txdav.caldav.datastore.test.util import buildCalendarStore, \
buildDirectoryRecord
from txdav.common.datastore.test.util import populateCalendarsFrom, CommonCommonTests
-import os
-
now = PyCalendarDateTime.getToday().getYear()
ORGANIZER_ICS = """BEGIN:VCALENDAR
@@ -111,22 +105,10 @@
@inlineCallbacks
def setUp(self):
- self.patch(config.DirectoryService.params, "xmlFile",
- os.path.join(
- os.path.dirname(__file__), "accounts.xml"
- )
- )
- self.patch(config.ResourceService.params, "xmlFile",
- os.path.join(
- os.path.dirname(__file__), "resources.xml"
- )
- )
-
yield super(RecipientCopy, self).setUp()
- self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory, directoryFromConfig(config))
+ self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory)
yield self.populate()
- self.rootResource = getRootResource(config, self._sqlCalendarStore)
self.directory = self._sqlCalendarStore.directoryService()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130424/87660f26/attachment-0001.html>
More information about the calendarserver-changes
mailing list