[CalendarServer-changes] [6187] CalendarServer/branches/generic-sqlstore
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 26 06:36:01 PDT 2010
Revision: 6187
http://trac.macosforge.org/projects/calendarserver/changeset/6187
Author: cdaboo at apple.com
Date: 2010-08-26 06:35:58 -0700 (Thu, 26 Aug 2010)
Log Message:
-----------
Fix up tests.
Modified Paths:
--------------
CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_calendarquery.py
CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_sharing.py
CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_wrapping.py
CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/sql.py
CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/test/test_sql.py
CalendarServer/branches/generic-sqlstore/txdav/carddav/datastore/test/common.py
CalendarServer/branches/generic-sqlstore/txdav/carddav/iaddressbookstore.py
CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_legacy.py
CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_tables.py
CalendarServer/branches/generic-sqlstore/txdav/common/datastore/test/util.py
Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_calendarquery.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_calendarquery.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_calendarquery.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -34,7 +34,7 @@
from twistedcaldav.config import config
from twistedcaldav.test.util import HomeTestCase
from twisted.internet.defer import inlineCallbacks, returnValue
-from txdav.caldav.datastore.test.test_postgres import buildStore
+from txdav.caldav.datastore.test.test_sql import buildStore
from txdav.caldav.datastore.test.common import StubNotifierFactory
Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_sharing.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_sharing.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -25,7 +25,7 @@
from twistedcaldav.config import config
from twistedcaldav.test.util import HomeTestCase, norequest
from twistedcaldav.resource import CalDAVResource
-from txdav.caldav.datastore.test.test_postgres import buildStore
+from txdav.caldav.datastore.test.test_sql import buildStore
from txdav.caldav.datastore.test.common import StubNotifierFactory
Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_wrapping.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/test/test_wrapping.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -41,7 +41,7 @@
from txdav.carddav.datastore.test.test_file import vcard4_text
-from txdav.caldav.datastore.test.test_postgres import buildStore
+from txdav.caldav.datastore.test.test_sql import buildStore
from txdav.caldav.datastore.test.common import StubNotifierFactory, \
assertProvides
from txdav.caldav.icalendarstore import ICalendarHome
Modified: CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/sql.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/sql.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/sql.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.caldav.datastore.test.test_postgres -*-
+# -*- test-case-name: txdav.base.propertystore.test.test_sql -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
Modified: CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/test/test_sql.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/test/test_sql.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/base/propertystore/test/test_sql.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -19,19 +19,12 @@
L{txdav.caldav.datastore.test.common}.
"""
+from twisted.internet.defer import inlineCallbacks
-from twext.python.filepath import CachingFilePath
-
-from twisted.internet import reactor
-from twisted.internet.defer import Deferred, inlineCallbacks, succeed
-from twisted.internet.task import deferLater
-from twisted.python import log
-
-from txdav.common.datastore.sql import v1_schema
from txdav.caldav.datastore.test.common import StubNotifierFactory
-from txdav.common.datastore.sql import CommonDataStore
-from txdav.base.datastore.subpostgres import PostgresService
+from txdav.common.datastore.test.util import SQLStoreBuilder
+
from txdav.base.propertystore.base import PropertyName
from txdav.base.propertystore.test import base
@@ -43,102 +36,7 @@
-class StoreBuilder(object):
- """
- Test-fixture-builder which can construct a PostgresStore.
- """
- sharedService = None
- currentTestID = None
-
- SHARED_DB_PATH = "../_test_postgres_db"
-
- def buildStore(self, testCase, notifierFactory):
- """
- Do the necessary work to build a store for a particular test case.
-
- @return: a L{Deferred} which fires with an L{IDataStore}.
- """
- currentTestID = testCase.id()
- dbRoot = CachingFilePath(self.SHARED_DB_PATH)
- if self.sharedService is None:
- ready = Deferred()
- def getReady(connectionFactory):
- attachmentRoot = dbRoot.child("attachments")
- try:
- attachmentRoot.createDirectory()
- except OSError:
- pass
- try:
- self.store = CommonDataStore(
- lambda label=None: connectionFactory(
- label or currentTestID
- ),
- notifierFactory,
- attachmentRoot
- )
- except:
- ready.errback()
- raise
- else:
- self.cleanDatabase(testCase)
- ready.callback(self.store)
- return self.store
- self.sharedService = PostgresService(
- dbRoot, getReady, v1_schema, "caldav", resetSchema=True,
- testMode=True
- )
- self.sharedService.startService()
- def startStopping():
- log.msg("Starting stopping.")
- self.sharedService.unpauseMonitor()
- return self.sharedService.stopService()
- reactor.addSystemEventTrigger(#@UndefinedVariable
- "before", "shutdown", startStopping)
- result = ready
- else:
- self.store.notifierFactory = notifierFactory
- self.cleanDatabase(testCase)
- result = succeed(self.store)
-
- def cleanUp():
- # FIXME: clean up any leaked connections and report them with an
- # immediate test failure.
- def stopit():
- self.sharedService.pauseMonitor()
- return deferLater(reactor, 0.1, stopit)
- testCase.addCleanup(cleanUp)
- return result
-
-
- def cleanDatabase(self, testCase):
- cleanupConn = self.store.connectionFactory(
- "%s schema-cleanup" % (testCase.id(),)
- )
- cursor = cleanupConn.cursor()
- tables = ['INVITE',
- 'RESOURCE_PROPERTY',
- 'ATTACHMENT',
- 'ADDRESSBOOK_OBJECT',
- 'CALENDAR_OBJECT',
- 'CALENDAR_BIND',
- 'ADDRESSBOOK_BIND',
- 'CALENDAR',
- 'ADDRESSBOOK',
- 'CALENDAR_HOME',
- 'ADDRESSBOOK_HOME',
- 'NOTIFICATION',
- 'NOTIFICATION_HOME']
- for table in tables:
- try:
- cursor.execute("delete from "+table)
- except:
- log.err()
- cleanupConn.commit()
- cleanupConn.close()
-
-
-
-theStoreBuilder = StoreBuilder()
+theStoreBuilder = SQLStoreBuilder()
buildStore = theStoreBuilder.buildStore
Modified: CalendarServer/branches/generic-sqlstore/txdav/carddav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/carddav/datastore/test/common.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/carddav/datastore/test/common.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.carddav.datastore,txdav.caldav.datastore.test.test_postgres.AddressBookSQLStorageTests -*-
+# -*- test-case-name: txdav.carddav.datastore,txdav.carddav.datastore.test.test_sql.AddressBookSQLStorageTests -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
Modified: CalendarServer/branches/generic-sqlstore/txdav/carddav/iaddressbookstore.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/carddav/iaddressbookstore.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/carddav/iaddressbookstore.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.carddav.datastore,txdav.caldav.datastore.test.test_postgres.AddressBookSQLStorageTests -*-
+# -*- test-case-name: txdav.carddav.datastore,txdav.carddav.datastore.test.test_sql.AddressBookSQLStorageTests -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
Modified: CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_legacy.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_legacy.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.caldav.datastore.test.test_postgres -*-
+# -*- test-case-name: txdav.caldav.datastore.test.test_sql -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
Modified: CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_tables.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_tables.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql_tables.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.caldav.datastore.test.test_postgres -*-
+# -*- test-case-name: txdav.caldav.datastore.test.test_sql -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
Modified: CalendarServer/branches/generic-sqlstore/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/txdav/common/datastore/test/util.py 2010-08-26 01:34:38 UTC (rev 6186)
+++ CalendarServer/branches/generic-sqlstore/txdav/common/datastore/test/util.py 2010-08-26 13:35:58 UTC (rev 6187)
@@ -52,7 +52,7 @@
sharedService = None
currentTestID = None
- SHARED_DB_PATH = "../_test_postgres_db"
+ SHARED_DB_PATH = "../_test_sql_db"
def buildStore(self, testCase, notifierFactory):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100826/12aed6f5/attachment-0001.html>
More information about the calendarserver-changes
mailing list