Beispiel #1
0
 def test_clear(self):
     queue = get_queue()
     delayed_queue = thread_queue.get_queue()
     delayed_queue.append((queue, divide, (1,), {'b': 1}))
     thread_queue.clear()
     delayed_queue = thread_queue.get_queue()
     self.assertEqual(delayed_queue, [])
Beispiel #2
0
 def test_clear(self):
     queue = get_queue()
     delayed_queue = thread_queue.get_queue()
     delayed_queue.append((queue, divide, (1,), {'b': 1}))
     thread_queue.clear()
     delayed_queue = thread_queue.get_queue()
     self.assertEqual(delayed_queue, [])
Beispiel #3
0
 def test_commit(self):
     """
     Ensure that commit_delayed_jobs properly enqueue jobs and clears
     delayed_queue.
     """
     queue = get_queue()
     delayed_queue = thread_queue.get_queue()
     queue.empty()
     self.assertEqual(queue.count, 0)
     queue.enqueue_call(divide, args=(1,), kwargs={'b': 1})
     thread_queue.commit()
     self.assertEqual(queue.count, 1)
     self.assertEqual(len(delayed_queue), 0)
Beispiel #4
0
 def test_commit(self):
     """
     Ensure that commit_delayed_jobs properly enqueue jobs and clears
     delayed_queue.
     """
     queue = get_queue()
     delayed_queue = thread_queue.get_queue()
     queue.empty()
     self.assertEqual(queue.count, 0)
     queue.enqueue_call(divide, args=(1,), kwargs={'b': 1})
     thread_queue.commit()
     self.assertEqual(queue.count, 1)
     self.assertEqual(len(delayed_queue), 0)
Beispiel #5
0
 def test_enqueue_autocommit_off(self):
     """
     Running ``enqueue`` when AUTOCOMMIT is off should
     put the job in the delayed queue instead of enqueueing it right away.
     """
     queue = get_queue()
     job = queue.enqueue(divide, 1, b=1)
     self.assertTrue(job is None)
     delayed_queue = thread_queue.get_queue()
     self.assertEqual(delayed_queue[0], (
         queue,
         (),
         {'args': (1,), 'result_ttl': None, 'timeout': None, 'func': divide, 'kwargs': {'b': 1}}
     ))
Beispiel #6
0
 def test_enqueue_autocommit_off(self):
     """
     Running ``enqueue`` when AUTOCOMMIT is off should
     put the job in the delayed queue instead of enqueueing it right away.
     """
     queue = get_queue()
     job = queue.enqueue(divide, 1, b=1)
     self.assertTrue(job is None)
     delayed_queue = thread_queue.get_queue()
     self.assertEqual(delayed_queue[0][0], queue)
     self.assertEqual(delayed_queue[0][1], ())
     kwargs = delayed_queue[0][2]
     self.assertEqual(kwargs['args'], (1,))
     self.assertEqual(kwargs['result_ttl'], None)
     self.assertEqual(kwargs['kwargs'], {'b': 1})
     self.assertEqual(kwargs['func'], divide)
     self.assertEqual(kwargs['timeout'], None)
Beispiel #7
0
 def test_enqueue_autocommit_off(self):
     """
     Running ``enqueue`` when AUTOCOMMIT is off should
     put the job in the delayed queue instead of enqueueing it right away.
     """
     queue = get_queue()
     job = queue.enqueue(divide, 1, b=1)
     self.assertTrue(job is None)
     delayed_queue = thread_queue.get_queue()
     self.assertEqual(delayed_queue[0][0], queue)
     self.assertEqual(delayed_queue[0][1], ())
     kwargs = delayed_queue[0][2]
     self.assertEqual(kwargs['args'], (1,))
     self.assertEqual(kwargs['result_ttl'], None)
     self.assertEqual(kwargs['kwargs'], {'b': 1})
     self.assertEqual(kwargs['func'], divide)
     self.assertEqual(kwargs['timeout'], None)