Queue cancelation test
This commit is contained in:
parent
8ca8c17e27
commit
dcfd379b17
1 changed files with 25 additions and 0 deletions
|
@ -244,6 +244,31 @@ class TestQueue(QueueTestCase):
|
|||
count = self.queue.num_available_jobs_between(now, now, 'abc')
|
||||
self.assertEqual(0, count)
|
||||
|
||||
def test_cancel(self):
|
||||
# Add an item.
|
||||
self.queue.put(['somenamespace', 'abc', 'def'], self.TEST_MESSAGE_1, available_after=-10)
|
||||
self.queue.put(['somenamespace', 'abc', 'def'], self.TEST_MESSAGE_2, available_after=-5)
|
||||
|
||||
now = datetime.utcnow()
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/somenamespace'])
|
||||
self.assertEqual(2, count)
|
||||
|
||||
# Retrieve it.
|
||||
item = self.queue.get()
|
||||
self.assertIsNotNone(item)
|
||||
|
||||
# Make sure we can cancel it.
|
||||
self.assertTrue(self.queue.cancel(item.id))
|
||||
|
||||
now = datetime.utcnow()
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/somenamespace'])
|
||||
self.assertEqual(1, count)
|
||||
|
||||
# Make sure it is gone.
|
||||
self.assertFalse(self.queue.cancel(item.id))
|
||||
|
||||
def test_deleted_namespaced_items(self):
|
||||
self.queue = AutoUpdatingQueue(WorkQueue(QUEUE_NAME, self.transaction_factory,
|
||||
reporter=self.reporter,
|
||||
|
|
Reference in a new issue