[CalendarServer-changes] [8812] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 5 07:11:14 PST 2012
Revision: 8812
http://trac.macosforge.org/projects/calendarserver/changeset/8812
Author: cdaboo at apple.com
Date: 2012-03-05 07:11:06 -0800 (Mon, 05 Mar 2012)
Log Message:
-----------
Fix unit tests leaving uncommitted transactions around.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/test/test_guidchange.py
CalendarServer/trunk/twistedcaldav/directory/test/util.py
CalendarServer/trunk/twistedcaldav/test/test_wrapping.py
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_guidchange.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_guidchange.py 2012-03-02 22:58:41 UTC (rev 8811)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_guidchange.py 2012-03-05 15:11:06 UTC (rev 8812)
@@ -1,5 +1,5 @@
##
-# Copyright (c) 2005-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2005-2012 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.
@@ -19,6 +19,7 @@
from twext.web2.dav.resource import AccessDeniedError
from twext.web2.test.test_server import SimpleRequest
+from twistedcaldav.directory.test.util import maybeCommit
from twistedcaldav.test.util import TestCase, xmlFile
@@ -103,6 +104,9 @@
self.fail("%s should not have %s privilege on %r" % (principal, privilege.sname(), resource))
d.addCallback(onSuccess)
d.addErrback(onError)
+ def _commit(ignore):
+ maybeCommit(request)
+ d.addBoth(_commit)
return d
d = request.locateResource(url)
Modified: CalendarServer/trunk/twistedcaldav/directory/test/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/util.py 2012-03-02 22:58:41 UTC (rev 8811)
+++ CalendarServer/trunk/twistedcaldav/directory/test/util.py 2012-03-05 15:11:06 UTC (rev 8812)
@@ -1,5 +1,5 @@
##
-# Copyright (c) 2005-2009 Apple Inc. All rights reserved.
+# Copyright (c) 2005-2012 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.
@@ -20,6 +20,7 @@
from twistedcaldav.directory.directory import DirectoryService
from twistedcaldav.directory.directory import UnknownRecordTypeError
+from twistedcaldav.directory.util import transactionFromRequest
from twistedcaldav.test.util import TestCase
# FIXME: Add tests for GUID hooey, once we figure out what that means here
@@ -348,3 +349,11 @@
self.failUnless(userRecord.verifyCredentials(credentials))
else:
self.failIf(userRecord.verifyCredentials(credentials))
+
+def maybeCommit(req):
+ class JustForCleanup(object):
+ def newTransaction(self, *whatever):
+ return self
+ def commit(self):
+ return
+ transactionFromRequest(req, JustForCleanup()).commit()
Modified: CalendarServer/trunk/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_wrapping.py 2012-03-02 22:58:41 UTC (rev 8811)
+++ CalendarServer/trunk/twistedcaldav/test/test_wrapping.py 2012-03-05 15:11:06 UTC (rev 8812)
@@ -1,5 +1,5 @@
##
-# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2012 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.
@@ -414,6 +414,8 @@
else:
self.fail("Error not raised, %r returned instead." %
(result,))
+ finally:
+ yield self.commit()
@inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120305/cbcad5ab/attachment.html>
More information about the calendarserver-changes
mailing list