本文整理汇总了Python中rq.registry.DeferredJobRegistry.add方法的典型用法代码示例。如果您正苦于以下问题:Python DeferredJobRegistry.add方法的具体用法?Python DeferredJobRegistry.add怎么用?Python DeferredJobRegistry.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rq.registry.DeferredJobRegistry
的用法示例。
在下文中一共展示了DeferredJobRegistry.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDeferredRegistry
# 需要导入模块: from rq.registry import DeferredJobRegistry [as 别名]
# 或者: from rq.registry.DeferredJobRegistry import add [as 别名]
class TestDeferredRegistry(RQTestCase):
def setUp(self):
super(TestDeferredRegistry, self).setUp()
self.registry = DeferredJobRegistry(connection=self.testconn)
def test_key(self):
self.assertEqual(self.registry.key, 'rq:deferred:default')
def test_add(self):
"""Adding a job to DeferredJobsRegistry."""
job = Job()
self.registry.add(job)
job_ids = [as_text(job_id) for job_id in
self.testconn.zrange(self.registry.key, 0, -1)]
self.assertEqual(job_ids, [job.id])
def test_register_dependency(self):
"""Ensure job creation and deletion works properly with DeferredJobRegistry."""
queue = Queue(connection=self.testconn)
job = queue.enqueue(say_hello)
job2 = queue.enqueue(say_hello, depends_on=job)
registry = DeferredJobRegistry(connection=self.testconn)
self.assertEqual(registry.get_job_ids(), [job2.id])
# When deleted, job removes itself from DeferredJobRegistry
job2.delete()
self.assertEqual(registry.get_job_ids(), [])
示例2: test_deferred_jobs
# 需要导入模块: from rq.registry import DeferredJobRegistry [as 别名]
# 或者: from rq.registry.DeferredJobRegistry import add [as 别名]
def test_deferred_jobs(self):
"""Ensure that active jobs page works properly."""
queue = get_queue('django_rq_test')
queue_index = get_queue_index('django_rq_test')
job = queue.enqueue(access_self)
registry = DeferredJobRegistry(queue.name, queue.connection)
registry.add(job, 2)
response = self.client.get(
reverse('rq_deferred_jobs', args=[queue_index])
)
self.assertEqual(response.context['jobs'], [job])
示例3: TestDeferredRegistry
# 需要导入模块: from rq.registry import DeferredJobRegistry [as 别名]
# 或者: from rq.registry.DeferredJobRegistry import add [as 别名]
class TestDeferredRegistry(RQTestCase):
def setUp(self):
super(TestDeferredRegistry, self).setUp()
self.registry = DeferredJobRegistry(connection=self.testconn)
def test_add(self):
"""Adding a job to DeferredJobsRegistry."""
job = Job()
self.registry.add(job)
job_ids = [as_text(job_id) for job_id in
self.testconn.zrange(self.registry.key, 0, -1)]
self.assertEqual(job_ids, [job.id])