本文整理汇总了Python中factories.AnonymousTaskRunFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python AnonymousTaskRunFactory.create_batch方法的具体用法?Python AnonymousTaskRunFactory.create_batch怎么用?Python AnonymousTaskRunFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factories.AnonymousTaskRunFactory
的用法示例。
在下文中一共展示了AnonymousTaskRunFactory.create_batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_progress_anonymous
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import create_batch [as 别名]
def test_user_progress_anonymous(self):
"""Test API userprogress as anonymous works"""
user = UserFactory.create()
app = AppFactory.create(owner=user)
tasks = TaskFactory.create_batch(2, app=app)
for task in tasks:
taskruns = AnonymousTaskRunFactory.create_batch(2, task=task)
taskruns = db.session.query(TaskRun)\
.filter(TaskRun.app_id == app.id)\
.filter(TaskRun.user_ip == '127.0.0.1')\
.all()
res = self.app.get('/api/app/1/userprogress', follow_redirects=True)
data = json.loads(res.data)
error_msg = "The reported total number of tasks is wrong"
assert len(tasks) == data['total'], error_msg
error_msg = "The reported number of done tasks is wrong"
assert len(taskruns) == data['done'], data
# Add a new TaskRun and check again
taskrun = AnonymousTaskRunFactory.create(task=tasks[0], info={'answer': u'hello'})
res = self.app.get('/api/app/1/userprogress', follow_redirects=True)
data = json.loads(res.data)
error_msg = "The reported total number of tasks is wrong"
assert len(tasks) == data['total'], error_msg
error_msg = "Number of done tasks is wrong: %s" % len(taskruns)
assert len(taskruns) + 1 == data['done'], error_msg
示例2: test_user_progress_anonymous
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import create_batch [as 别名]
def test_user_progress_anonymous(self):
"""Test API userprogress as anonymous works"""
user = UserFactory.create()
project = ProjectFactory.create(owner=user)
tasks = TaskFactory.create_batch(2, project=project)
taskruns = []
for task in tasks:
taskruns.extend(AnonymousTaskRunFactory.create_batch(2, task=task))
res = self.app.get('/api/project/1/userprogress', follow_redirects=True)
data = json.loads(res.data)
error_msg = "The reported total number of tasks is wrong"
assert len(tasks) == data['total'], error_msg
error_msg = "The reported number of done tasks is wrong"
assert len(taskruns) == data['done'], data
# Add a new TaskRun and check again
taskrun = AnonymousTaskRunFactory.create(task=tasks[0], info={'answer': u'hello'})
res = self.app.get('/api/project/1/userprogress', follow_redirects=True)
data = json.loads(res.data)
error_msg = "The reported total number of tasks is wrong"
assert len(tasks) == data['total'], error_msg
error_msg = "Number of done tasks is wrong: %s" % len(taskruns)
assert len(taskruns) + 1 == data['done'], error_msg