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


Python TaskAttemptFactory.create_batch方法代码示例

本文整理汇总了Python中oneanddone.tasks.tests.TaskAttemptFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python TaskAttemptFactory.create_batch方法的具体用法?Python TaskAttemptFactory.create_batch怎么用?Python TaskAttemptFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oneanddone.tasks.tests.TaskAttemptFactory的用法示例。


在下文中一共展示了TaskAttemptFactory.create_batch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_attempts_finished_count

# 需要导入模块: from oneanddone.tasks.tests import TaskAttemptFactory [as 别名]
# 或者: from oneanddone.tasks.tests.TaskAttemptFactory import create_batch [as 别名]
 def test_attempts_finished_count(self):
     """
     attempts_finished_count should return the number of attempts
     the user has finished.
     """
     user = UserFactory.create()
     TaskAttemptFactory.create_batch(4, user=user, state=TaskAttempt.FINISHED)
     TaskAttemptFactory.create(user=user, state=TaskAttempt.STARTED)
     eq_(user.attempts_finished_count, 4)
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:11,代码来源:test_models.py

示例2: test_close_stale_onetime_attempts

# 需要导入模块: from oneanddone.tasks.tests import TaskAttemptFactory [as 别名]
# 或者: from oneanddone.tasks.tests.TaskAttemptFactory import create_batch [as 别名]
 def test_close_stale_onetime_attempts(self):
     """
     The close_stale_onetime_attempts routine should close all
     expired one-time attempts, set them as requiring notification,
     and return the number that were closed.
     """
     task = TaskFactory.create(repeatable=False)
     user = UserFactory.create()
     recent_attempt, expired_attempt_1, expired_attempt_2 = TaskAttemptFactory.create_batch(
         3,
         user=user,
         state=TaskAttempt.STARTED,
         task=task)
     recent_attempt.created = aware_datetime(2014, 1, 29)
     recent_attempt.save()
     expired_attempt_1.created = aware_datetime(2014, 1, 1)
     expired_attempt_1.save()
     expired_attempt_2.created = aware_datetime(2014, 1, 1)
     expired_attempt_2.save()
     eq_(task.taskattempt_set.filter(state=TaskAttempt.STARTED).count(), 3)
     with patch('oneanddone.tasks.models.timezone.now') as now:
         now.return_value = aware_datetime(2014, 1, 31)
         eq_(TaskAttempt.close_stale_onetime_attempts(), 2)
     eq_(TaskAttempt.objects.filter(task=task,
                                    state=TaskAttempt.STARTED).count(), 1)
     eq_(TaskAttempt.objects.filter(task=task,
                                    state=TaskAttempt.CLOSED,
                                    requires_notification=True).count(), 2)
开发者ID:akatsoulas,项目名称:oneanddone,代码行数:30,代码来源:test_models.py

示例3: test_attempts_in_progress

# 需要导入模块: from oneanddone.tasks.tests import TaskAttemptFactory [as 别名]
# 或者: from oneanddone.tasks.tests.TaskAttemptFactory import create_batch [as 别名]
 def test_attempts_in_progress(self):
     """
     attempts_in_progress should return the number of attempts in progress.
     """
     user = UserFactory.create()
     tasks = TaskAttemptFactory.create_batch(4, user=user, state=TaskAttempt.STARTED)
     eq_(set(user.attempts_in_progress), set(tasks))
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:9,代码来源:test_models.py

示例4: setUp

# 需要导入模块: from oneanddone.tasks.tests import TaskAttemptFactory [as 别名]
# 或者: from oneanddone.tasks.tests.TaskAttemptFactory import create_batch [as 别名]
 def setUp(self):
     self.user1, self.user2 = UserFactory.create_batch(2)
     self.task1, self.task2 = TaskFactory.create_batch(2)
     TaskAttemptFactory.create_batch(2,
                                     user=self.user1,
                                     task=self.task1,
                                     state=TaskAttempt.FINISHED)
     ValidTaskAttemptFactory.create_batch(2,
                                          user=self.user1,
                                          task=self.task1,
                                          state=TaskAttempt.FINISHED)
     ValidTaskAttemptFactory.create(user=self.user1,
                                    task=self.task2,
                                    state=TaskAttempt.FINISHED)
     ValidTaskAttemptFactory.create(user=self.user2,
                                    task=self.task1,
                                    state=TaskAttempt.FINISHED)
     ValidTaskAttemptFactory.create_batch(2,
                                          user=self.user1,
                                          task=self.task1,
                                          state=TaskAttempt.ABANDONED)
     ValidTaskAttemptFactory.create(user=self.user2,
                                    task=self.task1,
                                    state=TaskAttempt.ABANDONED)
     ValidTaskAttemptFactory.create(user=self.user1,
                                    task=self.task2,
                                    state=TaskAttempt.ABANDONED)
     ValidTaskAttemptFactory.create_batch(2,
                                          user=self.user1,
                                          task=self.task1,
                                          state=TaskAttempt.CLOSED)
     ValidTaskAttemptFactory.create(user=self.user2,
                                    task=self.task1,
                                    state=TaskAttempt.CLOSED)
     ValidTaskAttemptFactory.create(user=self.user1,
                                    task=self.task2,
                                    state=TaskAttempt.CLOSED)
开发者ID:akatsoulas,项目名称:oneanddone,代码行数:39,代码来源:test_models.py

示例5: test_attempts_in_progress

# 需要导入模块: from oneanddone.tasks.tests import TaskAttemptFactory [as 别名]
# 或者: from oneanddone.tasks.tests.TaskAttemptFactory import create_batch [as 别名]
 def test_attempts_in_progress(self):
     user = UserFactory.create()
     tasks = TaskAttemptFactory.create_batch(4, user=user, state=TaskAttempt.STARTED)
     eq_(set(user.attempts_in_progress), set(tasks))
开发者ID:bitgeeky,项目名称:oneanddone,代码行数:6,代码来源:test_models.py

示例6: test_attempts_finished_count

# 需要导入模块: from oneanddone.tasks.tests import TaskAttemptFactory [as 别名]
# 或者: from oneanddone.tasks.tests.TaskAttemptFactory import create_batch [as 别名]
 def test_attempts_finished_count(self):
     user = UserFactory.create()
     TaskAttemptFactory.create_batch(4, user=user, state=TaskAttempt.FINISHED)
     TaskAttemptFactory.create(user=user, state=TaskAttempt.STARTED)
     eq_(user.attempts_finished_count, 4)
开发者ID:bitgeeky,项目名称:oneanddone,代码行数:7,代码来源:test_models.py


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