[CalendarServer-changes] [11299] CalendarServer/branches/users/glyph/q-delete-no-concurrency/twext/ enterprise/test/test_queue.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 5 11:42:09 PDT 2013
Revision: 11299
http://trac.calendarserver.org//changeset/11299
Author: glyph at apple.com
Date: 2013-06-05 11:42:09 -0700 (Wed, 05 Jun 2013)
Log Message:
-----------
Test fixture: allow us to simulate a concurrent deletion.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/q-delete-no-concurrency/twext/enterprise/test/test_queue.py
Modified: CalendarServer/branches/users/glyph/q-delete-no-concurrency/twext/enterprise/test/test_queue.py
===================================================================
--- CalendarServer/branches/users/glyph/q-delete-no-concurrency/twext/enterprise/test/test_queue.py 2013-06-05 17:52:06 UTC (rev 11298)
+++ CalendarServer/branches/users/glyph/q-delete-no-concurrency/twext/enterprise/test/test_queue.py 2013-06-05 18:42:09 UTC (rev 11299)
@@ -54,6 +54,7 @@
from zope.interface.verify import verifyObject
from twisted.test.proto_helpers import StringTransport, MemoryReactor
from twext.enterprise.fixtures import SteppablePoolHelper
+from twisted.internet.defer import returnValue
from twext.enterprise.queue import _BaseQueuer, NonPerformingQueuer
import twext.enterprise.queue
@@ -157,7 +158,8 @@
schemaText = SQL("""
create table DUMMY_WORK_ITEM (WORK_ID integer primary key,
NOT_BEFORE timestamp,
- A integer, B integer);
+ A integer, B integer,
+ DELETE_ON_LOAD integer default 0);
create table DUMMY_WORK_DONE (WORK_ID integer primary key,
A_PLUS_B integer);
""")
@@ -194,7 +196,22 @@
aPlusB=self.a + self.b)
+ @classmethod
+ @inlineCallbacks
+ def load(cls, *a, **kw):
+ """
+ Load L{DummyWorkItem} as normal... unless the loaded item has
+ C{DELETE_ON_LOAD} set, in which case, simulate a concurrent transaction
+ doing a delete/commit immediately after load (by just doing it in the
+ same transaction).
+ """
+ self = yield super(DummyWorkItem, cls).load(*a, **kw)
+ if self.deleteOnLoad:
+ yield self.delete()
+ returnValue(self)
+
+
class SchemaAMPTests(TestCase):
"""
Tests for L{SchemaAMP} faithfully relaying tables across the wire.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130605/93b76df8/attachment.html>
More information about the calendarserver-changes
mailing list