本文整理汇总了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)
示例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)
示例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))
示例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)
示例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))
示例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)