当前位置: 首页>>代码示例>>Python>>正文


Python DeferredJobRegistry.add方法代码示例

本文整理汇总了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(), [])
开发者ID:qq18436558,项目名称:rq,代码行数:31,代码来源:test_registry.py

示例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])
开发者ID:smaccona,项目名称:django-rq,代码行数:14,代码来源:tests.py

示例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])
开发者ID:AaronWan,项目名称:rq,代码行数:15,代码来源:test_registry.py


注:本文中的rq.registry.DeferredJobRegistry.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。