Skip to content

Commit

Permalink
rqflush interactive and documented [see rq#218] (remove some unues te…
Browse files Browse the repository at this point in the history
…st cases)
  • Loading branch information
depaolim committed Feb 14, 2017
1 parent f9c69f7 commit f960a48
Showing 1 changed file with 0 additions and 67 deletions.
67 changes: 0 additions & 67 deletions django_rq/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,73 +620,6 @@ def test_error(self):
self.assertEqual(queue.count, 0)


class ThreadQueueWithTransactionAtomicTest(TestCase):

@override_settings(RQ={'AUTOCOMMIT': True})
def test_enqueue_autocommit_on(self):
"""
Running ``enqueue`` when AUTOCOMMIT is on should
immediately persist job into Redis.
"""
queue = get_queue()
queue.empty()
with transaction.atomic():
job = queue.enqueue(divide, 1, 1)
self.assertTrue(job.id in queue.job_ids)
job.delete()

@override_settings(RQ={'AUTOCOMMIT': False})
def test_enqueue_autocommit_off(self):
"""
Running ``enqueue`` when AUTOCOMMIT is off should
puts the job in the delayed queue but ...
"""
thread_queue.clear()
queue = get_queue()
queue.empty()
with transaction.atomic():
queue.enqueue(divide, 1, 1)

# the following call SHOULDN'T BE necessary
# it should be called by an on_commit hook
# https://docs.djangoproject.com/en/1.10/topics/db/transactions/#django.db.transaction.on_commit
thread_queue.commit()

job = queue.dequeue()
self.assertTrue(job)
self.assertTrue(job.func.func_name, "divide")
job.delete()
self.assertFalse(queue.dequeue())

@override_settings(RQ={'AUTOCOMMIT': False})
def test_enqueue_autocommit_offand_db_error(self):
"""
Running ``enqueue`` when AUTOCOMMIT is off should
puts the job in the delayed queue only if dba transaction succedes
"""
thread_queue.clear()
queue = get_queue()
queue.empty()

try:
with transaction.atomic():
queue.enqueue(divide, 1, 1)
# something went wrong on DB
assert False
except AssertionError:
# the following call SHOULDN'T BE necessary
# but if you don't make it, the final situation would be inconsistent:
# DB transaction has failed but job is enqueued
thread_queue.clear()

# the following call SHOULDN'T BE necessary
thread_queue.commit()

job = queue.dequeue()
self.assertFalse(job)
self.assertFalse(queue.dequeue())


class SchedulerTest(TestCase):

@skipIf(RQ_SCHEDULER_INSTALLED is False, 'RQ Scheduler not installed')
Expand Down

0 comments on commit f960a48

Please sign in to comment.