[CalendarServer-changes] [6026] CalendarServer/branches/users/glyph/sql-store
source_changes at macosforge.org
source_changes at macosforge.org
Tue Aug 10 08:10:47 PDT 2010
Revision: 6026
http://trac.macosforge.org/projects/calendarserver/changeset/6026
Author: sagen at apple.com
Date: 2010-08-10 08:10:43 -0700 (Tue, 10 Aug 2010)
Log Message:
-----------
Fixes more tests
Modified Paths:
--------------
CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py
CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/test/common.py
CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/test/common.py
Modified: CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py 2010-08-10 14:18:46 UTC (rev 6025)
+++ CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py 2010-08-10 15:10:43 UTC (rev 6026)
@@ -1519,7 +1519,7 @@
# FIXME: not specified on the interface or exercised by the tests, but
# required by clients of the implementation!
rows = self._txn.execSQL(
- "select ADDRESSBOOK_RESOURCE_NAME from ADDRESS_BIND where "
+ "select ADDRESSBOOK_RESOURCE_NAME from ADDRESSBOOK_BIND where "
"ADDRESSBOOK_HOME_RESOURCE_ID = %s "
"AND BIND_STATUS != %s",
[self._resourceID, _BIND_STATUS_DECLINED]
Modified: CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/test/common.py 2010-08-10 14:18:46 UTC (rev 6025)
+++ CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/test/common.py 2010-08-10 15:10:43 UTC (rev 6026)
@@ -240,8 +240,7 @@
"""
Get the calendar home detailed by C{requirements['home1']}.
"""
- return self.transactionUnderTest().calendarHomeWithUID(
- "home1")
+ return self.transactionUnderTest().calendarHomeWithUID("home1")
def calendarUnderTest(self):
@@ -392,8 +391,7 @@
self.commit()
# Make sure notification fired after commit
- self.assertEquals(self.notifierFactory.history,
- [("update", "home1")])
+ self.assertTrue(self.notifierFactory.compare([("update", "home1")]))
# Make sure it's available in a new transaction; i.e. test the commit.
home = self.homeUnderTest()
Modified: CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/test/common.py 2010-08-10 14:18:46 UTC (rev 6025)
+++ CalendarServer/branches/users/glyph/sql-store/txcarddav/addressbookstore/test/common.py 2010-08-10 15:10:43 UTC (rev 6026)
@@ -103,7 +103,23 @@
)
+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 CommonTests(object):
"""
Tests for common functionality of interfaces defined in
@@ -149,7 +165,7 @@
return self.lastTransaction
if self.savedStore is None:
self.savedStore = self.storeUnderTest()
- txn = self.lastTransaction = self.savedStore.newTransaction()
+ txn = self.lastTransaction = self.savedStore.newTransaction(self.id())
return txn
@@ -173,6 +189,12 @@
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']}.
@@ -195,22 +217,9 @@
return self.addressbookUnderTest().addressbookObjectWithName("1.vcf")
- def assertProvides(self, interface, provider):
- """
- Verify that C{provider} properly provides C{interface}
+ assertProvides = assertProvides
- @type interface: L{zope.interface.Interface}
- @type provider: C{provider}
- """
- try:
- verifyObject(interface, provider)
- except BrokenMethodImplementation, e:
- self.fail(e)
- except DoesNotImplement, e:
- self.fail("%r does not provide %s.%s" %
- (provider, interface.__module__, interface.getName()))
-
def test_addressbookStoreProvides(self):
"""
The addressbook store provides L{IAddressBookStore} and its required
@@ -225,7 +234,7 @@
The transactions generated by the addressbook store provide
L{IAddressBookStoreTransaction} and its required attributes.
"""
- txn = self.storeUnderTest().newTransaction()
+ txn = self.transactionUnderTest()
self.assertProvides(ICommonTransaction, txn)
self.assertProvides(IAddressBookTransaction, txn)
@@ -260,9 +269,8 @@
provides L{IAddressBookHome} and has a C{uid()} method that returns the
same value that was passed in.
"""
- addressbookHome = (self.storeUnderTest().newTransaction()
+ addressbookHome = (self.transactionUnderTest()
.addressbookHomeWithUID("home1"))
-
self.assertEquals(addressbookHome.uid(), "home1")
self.assertProvides(IAddressBookHome, addressbookHome)
@@ -272,11 +280,8 @@
L{IAddressBookStoreTransaction.addressbookHomeWithUID} should return C{None}
when asked for a non-existent addressbook home.
"""
- self.assertEquals(
- self.storeUnderTest().newTransaction()
- .addressbookHomeWithUID("xyzzy"),
- None
- )
+ txn = self.transactionUnderTest()
+ self.assertEquals(txn.addressbookHomeWithUID("xyzzy"), None)
def test_addressbookWithName_exists(self):
@@ -287,6 +292,8 @@
home = self.homeUnderTest()
for name in home1_addressbookNames:
addressbook = home.addressbookWithName(name)
+ if addressbook is None:
+ self.fail("addressbook %r didn't exist" % (name,))
self.assertProvides(IAddressBook, addressbook)
self.assertEquals(addressbook.name(), name)
@@ -337,7 +344,8 @@
addressbookProperties[
PropertyName.fromString(davxml.ResourceType.sname())
],
- davxml.ResourceType.addressbook) #@UndefinedVariable
+ davxml.ResourceType.addressbook
+ ) #@UndefinedVariable
checkProperties()
self.commit()
@@ -347,8 +355,11 @@
# Make sure it's available in a new transaction; i.e. test the commit.
home = self.homeUnderTest()
self.assertNotIdentical(home.addressbookWithName(name), None)
- home = self.addressbookStore.newTransaction().addressbookHomeWithUID(
- "home1")
+
+ # FIXME: These two lines aren't in the calendar common tests:
+ # home = self.addressbookStore.newTransaction().addressbookHomeWithUID(
+ # "home1")
+
# Sanity check: are the properties actually persisted?
# FIXME: no independent testing of this right now
checkProperties()
@@ -411,8 +422,8 @@
)
self.assertEquals(
- list(o.name() for o in addressbookObjects),
- addressbook1_objectNames
+ set(o.name() for o in addressbookObjects),
+ set(addressbook1_objectNames)
)
@@ -598,8 +609,8 @@
home.addressbookWithName(addressbook.name()))
self.assertEquals(
- list(c.name() for c in addressbooks),
- home1_addressbookNames
+ set(c.name() for c in addressbooks),
+ set(home1_addressbookNames)
)
@@ -707,8 +718,9 @@
create=True
)
def readOtherTxn():
- return self.savedStore.newTransaction().addressbookHomeWithUID(
- noHomeUID)
+ otherTxn = self.savedStore.newTransaction()
+ self.addCleanup(otherTxn.commit)
+ return otherTxn.addressbookHomeWithUID(noHomeUID)
self.assertProvides(IAddressBookHome, addressbookHome)
# A concurrent transaction shouldn't be able to read it yet:
self.assertIdentical(readOtherTxn(), None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100810/6f773ece/attachment-0001.html>
More information about the calendarserver-changes
mailing list