[CalendarServer-changes] [6341] CalendarServer/branches/users/glyph/more-deferreds-6
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 22 20:37:28 PDT 2010
Revision: 6341
http://trac.macosforge.org/projects/calendarserver/changeset/6341
Author: glyph at apple.com
Date: 2010-09-22 20:37:27 -0700 (Wed, 22 Sep 2010)
Log Message:
-----------
add more asyncness to tests
Modified Paths:
--------------
CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_calendarquery.py
CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sharing.py
CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sql.py
CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/common.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/common.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/test_file.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_calendarquery.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_calendarquery.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_calendarquery.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -34,8 +34,7 @@
from twistedcaldav.config import config
from twistedcaldav.test.util import HomeTestCase
from twisted.internet.defer import inlineCallbacks, returnValue
-from txdav.common.datastore.test.util import buildStore
-from txdav.caldav.datastore.test.common import StubNotifierFactory
+from txdav.common.datastore.test.util import buildStore, StubNotifierFactory
@inlineCallbacks
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sharing.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sharing.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -25,8 +25,7 @@
from twistedcaldav.config import config
from twistedcaldav.test.util import HomeTestCase, norequest
from twistedcaldav.resource import CalDAVResource
-from txdav.common.datastore.test.util import buildStore
-from txdav.caldav.datastore.test.common import StubNotifierFactory
+from txdav.common.datastore.test.util import buildStore, StubNotifierFactory
sharedOwnerType = davxml.ResourceType.sharedownercalendar #@UndefinedVariable
regularCalendarType = davxml.ResourceType.calendar #@UndefinedVariable
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sql.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_sql.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -17,7 +17,7 @@
from twistedcaldav.sql import AbstractSQLDatabase
import twistedcaldav.test.util
-from twistedcaldav.sql import db_prefix
+
from threading import Thread
import time
import os
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -41,9 +41,10 @@
from txdav.carddav.datastore.test.test_file import vcard4_text
-from txdav.common.datastore.test.util import buildStore
-from txdav.caldav.datastore.test.common import StubNotifierFactory, \
- assertProvides
+from txdav.common.datastore.test.util import buildStore, assertProvides,\
+ StubNotifierFactory
+
+
from txdav.caldav.icalendarstore import ICalendarHome
from txdav.carddav.iaddressbookstore import IAddressBookHome
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -21,10 +21,8 @@
from twisted.internet.defer import inlineCallbacks
-from txdav.caldav.datastore.test.common import StubNotifierFactory
+from txdav.common.datastore.test.util import buildStore, StubNotifierFactory
-from txdav.common.datastore.test.util import buildStore
-
from txdav.base.propertystore.base import PropertyName
from txdav.base.propertystore.test import base
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/common.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/common.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -19,10 +19,6 @@
Tests for common calendar store API functions.
"""
-from zope.interface.verify import verifyObject
-from zope.interface.exceptions import (
- BrokenMethodImplementation, DoesNotImplement)
-
from twisted.internet.defer import Deferred, inlineCallbacks
from twisted.internet.protocol import Protocol
@@ -36,6 +32,7 @@
from txdav.common.icommondatastore import NoSuchObjectResourceError
from txdav.common.icommondatastore import ObjectResourceNameAlreadyExistsError
from txdav.common.inotifications import INotificationObject
+from txdav.common.datastore.test.util import CommonCommonTests
from txdav.caldav.icalendarstore import (
ICalendarObject, ICalendarHome,
@@ -47,7 +44,6 @@
from twext.web2.dav.element.base import WebDAVUnknownElement
from twext.python.vcomponent import VComponent
-from twistedcaldav.notify import Notifier
from twistedcaldav.customxml import InviteNotification, InviteSummary
storePath = FilePath(__file__).parent().child("calendar_store")
@@ -146,24 +142,8 @@
-def assertProvides(testCase, interface, provider):
+class CommonTests(CommonCommonTests):
"""
- Verify that C{provider} properly provides C{interface}
-
- @type interface: L{zope.interface.Interface}
- @type provider: C{provider}
- """
- try:
- verifyObject(interface, provider)
- except BrokenMethodImplementation, e:
- testCase.fail(e)
- except DoesNotImplement, e:
- testCase.fail("%r does not provide %s.%s" %
- (provider, interface.__module__, interface.getName()))
-
-
-class CommonTests(object):
- """
Tests for common functionality of interfaces defined in
L{txdav.caldav.icalendarstore}.
"""
@@ -194,50 +174,6 @@
raise NotImplementedError()
- lastTransaction = None
- savedStore = None
-
- def transactionUnderTest(self):
- """
- Create a transaction from C{storeUnderTest} and save it as
- C[lastTransaction}. Also makes sure to use the same store, saving the
- value from C{storeUnderTest}.
- """
- if self.lastTransaction is not None:
- return self.lastTransaction
- if self.savedStore is None:
- self.savedStore = self.storeUnderTest()
- txn = self.lastTransaction = self.savedStore.newTransaction(self.id())
- return txn
-
-
- def commit(self):
- """
- Commit the last transaction created from C{transactionUnderTest}, and
- clear it.
- """
- self.lastTransaction.commit()
- self.lastTransaction = None
-
-
- def abort(self):
- """
- Abort the last transaction created from C[transactionUnderTest}, and
- clear it.
- """
- self.lastTransaction.abort()
- self.lastTransaction = None
-
-
- def setUp(self):
- self.notifierFactory = StubNotifierFactory()
-
-
- def tearDown(self):
- if self.lastTransaction is not None:
- self.commit()
-
-
def homeUnderTest(self):
"""
Get the calendar home detailed by C{requirements['home1']}.
@@ -260,8 +196,6 @@
return self.calendarUnderTest().calendarObjectWithName("1.ics")
- assertProvides = assertProvides
-
def test_calendarStoreProvides(self):
"""
The calendar store provides L{IDataStore} and its required attributes.
@@ -1219,18 +1153,3 @@
-class StubNotifierFactory(object):
-
- """ For testing push notifications without an XMPP server """
-
- def __init__(self):
- self.reset()
-
- def newNotifier(self, label="default", id=None, prefix=None):
- return Notifier(self, label=label, id=id, prefix=prefix)
-
- def send(self, op, id):
- self.history.append((op, id))
-
- def reset(self):
- self.history = []
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/common.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/common.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -18,11 +18,6 @@
Tests for common addressbook store API functions.
"""
-from zope.interface.verify import verifyObject
-from zope.interface.exceptions import (
- BrokenMethodImplementation, DoesNotImplement
-)
-
from txdav.idav import IPropertyStore, IDataStore
from txdav.base.propertystore.base import PropertyName
@@ -38,8 +33,10 @@
IAddressBookObject, IAddressBookHome,
IAddressBook, IAddressBookTransaction
)
+
+from txdav.common.datastore.test.util import CommonCommonTests
+
from twistedcaldav.vcard import Component as VComponent
-from twistedcaldav.notify import Notifier
from twext.python.filepath import CachingFilePath as FilePath
from twext.web2.dav import davxml
@@ -103,25 +100,8 @@
)
-def assertProvides(testCase, interface, provider):
+class CommonTests(CommonCommonTests):
"""
- Verify that C{provider} properly provides C{interface}
-
- @type interface: L{zope.interface.Interface}
- @type provider: C{provider}
- """
- try:
- verifyObject(interface, provider)
- except BrokenMethodImplementation, e:
- testCase.fail(e)
- except DoesNotImplement, e:
- testCase.fail("%r does not provide %s.%s" %
- (provider, interface.__module__, interface.getName()))
-
-
-
-class CommonTests(object):
- """
Tests for common functionality of interfaces defined in
L{txdav.carddav.iaddressbookstore}.
"""
@@ -152,49 +132,6 @@
raise NotImplementedError()
- lastTransaction = None
- savedStore = None
-
- def transactionUnderTest(self):
- """
- Create a transaction from C{storeUnderTest} and save it as
- C[lastTransaction}. Also makes sure to use the same store, saving the
- value from C{storeUnderTest}.
- """
- if self.lastTransaction is not None:
- return self.lastTransaction
- if self.savedStore is None:
- self.savedStore = self.storeUnderTest()
- txn = self.lastTransaction = self.savedStore.newTransaction(self.id())
- return txn
-
-
- def commit(self):
- """
- Commit the last transaction created from C{transactionUnderTest}, and
- clear it.
- """
- self.lastTransaction.commit()
- self.lastTransaction = None
-
-
- def abort(self):
- """
- Abort the last transaction created from C[transactionUnderTest}, and
- clear it.
- """
- self.lastTransaction.abort()
- self.lastTransaction = None
-
- def setUp(self):
- self.notifierFactory = StubNotifierFactory()
-
- def tearDown(self):
- if self.lastTransaction is not None:
- self.commit()
-
-
-
def homeUnderTest(self):
"""
Get the addressbook home detailed by C{requirements['home1']}.
@@ -217,9 +154,6 @@
return self.addressbookUnderTest().addressbookObjectWithName("1.vcf")
- assertProvides = assertProvides
-
-
def test_addressbookStoreProvides(self):
"""
The addressbook store provides L{IAddressBookStore} and its required
@@ -915,18 +849,3 @@
-class StubNotifierFactory(object):
-
- """ For testing push notifications without an XMPP server """
-
- def __init__(self):
- self.reset()
-
- def newNotifier(self, label="default", id=None, prefix=None):
- return Notifier(self, label=label, id=id, prefix=prefix)
-
- def send(self, op, id):
- self.history.append((op, id))
-
- def reset(self):
- self.history = []
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/test_file.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/test_file.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/carddav/datastore/test/test_file.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -33,8 +33,10 @@
from txdav.carddav.datastore.file import AddressBook, AddressBookObject
from txdav.carddav.datastore.test.common import (
- CommonTests, vcard4_text, vcard1modified_text, StubNotifierFactory)
+ CommonTests, vcard4_text, vcard1modified_text)
+from txdav.common.datastore.test.util import StubNotifierFactory
+
storePath = FilePath(__file__).parent().child("addressbook_store")
def _todo(f, why):
@@ -420,7 +422,7 @@
)
-class FileStorageTests(unittest.TestCase, CommonTests):
+class FileStorageTests(CommonTests, unittest.TestCase):
"""
File storage tests.
"""
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -27,8 +27,8 @@
from txdav.common.datastore.util import UpgradeToDatabaseService
from txdav.common.datastore.file import CommonDataStore
from txdav.common.datastore.test.util import theStoreBuilder, \
- populateCalendarsFrom
-from txdav.caldav.datastore.test.common import StubNotifierFactory, CommonTests
+ populateCalendarsFrom, StubNotifierFactory
+from txdav.caldav.datastore.test.common import CommonTests
from twisted.internet.defer import inlineCallbacks, Deferred, returnValue
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py 2010-09-23 01:49:58 UTC (rev 6340)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py 2010-09-23 03:37:27 UTC (rev 6341)
@@ -20,6 +20,9 @@
"""
import gc
+from zope.interface.verify import verifyObject
+from zope.interface.exceptions import BrokenMethodImplementation,\
+ DoesNotImplement
from twext.python.filepath import CachingFilePath
from twext.python.vcomponent import VComponent
@@ -33,6 +36,7 @@
from txdav.base.datastore.subpostgres import PostgresService,\
DiagnosticConnectionWrapper
from txdav.common.icommondatastore import NoSuchHomeChildError
+from twistedcaldav.notify import Notifier
def allInstancesOf(cls):
@@ -179,3 +183,88 @@
)
populateTxn.commit()
+
+def assertProvides(testCase, interface, provider):
+ """
+ Verify that C{provider} properly provides C{interface}
+
+ @type interface: L{zope.interface.Interface}
+ @type provider: C{provider}
+ """
+ try:
+ verifyObject(interface, provider)
+ except BrokenMethodImplementation, e:
+ testCase.fail(e)
+ except DoesNotImplement, e:
+ testCase.fail("%r does not provide %s.%s" %
+ (provider, interface.__module__, interface.getName()))
+
+
+
+class CommonCommonTests(object):
+ """
+ Common utility functionality for file/store combination tests.
+ """
+
+ lastTransaction = None
+ savedStore = None
+ assertProvides = assertProvides
+
+ def transactionUnderTest(self):
+ """
+ Create a transaction from C{storeUnderTest} and save it as
+ C[lastTransaction}. Also makes sure to use the same store, saving the
+ value from C{storeUnderTest}.
+ """
+ if self.lastTransaction is not None:
+ return self.lastTransaction
+ if self.savedStore is None:
+ self.savedStore = self.storeUnderTest()
+ self.counter += 1
+ txn = self.lastTransaction = self.savedStore.newTransaction(self.id() + " #" + str(self.counter))
+ return txn
+
+
+ def commit(self):
+ """
+ Commit the last transaction created from C{transactionUnderTest}, and
+ clear it.
+ """
+ self.lastTransaction.commit()
+ self.lastTransaction = None
+
+
+ def abort(self):
+ """
+ Abort the last transaction created from C[transactionUnderTest}, and
+ clear it.
+ """
+ self.lastTransaction.abort()
+ self.lastTransaction = None
+
+ def setUp(self):
+ self.counter = 0
+ self.notifierFactory = StubNotifierFactory()
+
+ def tearDown(self):
+ if self.lastTransaction is not None:
+ self.commit()
+
+
+
+class StubNotifierFactory(object):
+ """
+ For testing push notifications without an XMPP server.
+ """
+
+ def __init__(self):
+ self.reset()
+
+ def newNotifier(self, label="default", id=None, prefix=None):
+ return Notifier(self, label=label, id=id, prefix=prefix)
+
+ def send(self, op, id):
+ self.history.append((op, id))
+
+ def reset(self):
+ self.history = []
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100922/49548ce7/attachment-0001.html>
More information about the calendarserver-changes
mailing list