summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJahn Thomas Fidje <jtfidje@gmail.com>2022-09-23 03:06:37 +0200
committerGitHub <noreply@github.com>2022-09-23 08:06:37 +0700
commit840438559261fd64b07d1bce489d352e6d553da5 (patch)
treeb5f45d98551301e299fc65ec518c87d420feba53 /tests
parent108c2ea66652737aa54038f7d71477af625b58eb (diff)
downloadrq-840438559261fd64b07d1bce489d352e6d553da5.tar.gz
Add feature to enqueue dependents at the front of queues (#1696)
* Add feature to enqueue dependents at the front of queues * Add documentation for the Dependency(enqueue_at_front=...) parameter * docs: Add `enqueue_at_front` to list of parameters for Dependency * test: Update dependency test to not rely on Redis ordering * refactor: Save enqueue_at_front boolean in job.meta instead of separate instance attr * fix: Made enqueue_at_front an instance attribute instead of putting it inside meta
Diffstat (limited to 'tests')
-rw-r--r--tests/test_dependencies.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_dependencies.py b/tests/test_dependencies.py
index 12b956d..d379ed9 100644
--- a/tests/test_dependencies.py
+++ b/tests/test_dependencies.py
@@ -98,6 +98,25 @@ class TestDependencies(RQTestCase):
job = Job.fetch(job.id, connection=self.testconn)
self.assertEqual(job.get_status(), JobStatus.FINISHED)
+ # Test dependant is enqueued at front
+ q.empty()
+ parent_job = q.enqueue(say_hello)
+ q.enqueue(
+ say_hello,
+ job_id='fake_job_id_1',
+ depends_on=Dependency(jobs=[parent_job])
+ )
+ q.enqueue(
+ say_hello,
+ job_id='fake_job_id_2',
+ depends_on=Dependency(jobs=[parent_job],enqueue_at_front=True)
+ )
+ #q.enqueue(say_hello) # This is a filler job that will act as a separator for jobs, one will be enqueued at front while the other one at the end of the queue
+ w.work(burst=True, max_jobs=1)
+
+ self.assertEqual(q.job_ids, ["fake_job_id_2", "fake_job_id_1"])
+
+
def test_dependencies_are_met_if_parent_is_canceled(self):
"""When parent job is canceled, it should be treated as failed"""
queue = Queue(connection=self.testconn)