本文整理汇总了Python中factories.AnonymousTaskRunFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python AnonymousTaskRunFactory.build方法的具体用法?Python AnonymousTaskRunFactory.build怎么用?Python AnonymousTaskRunFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factories.AnonymousTaskRunFactory
的用法示例。
在下文中一共展示了AnonymousTaskRunFactory.build方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_anonymous_user_create_repeated_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_repeated_taskrun(self):
"""Test anonymous user cannot create two taskruns for the same task"""
task = TaskFactory.create()
taskrun1 = AnonymousTaskRunFactory.create(task=task)
taskrun2 = AnonymousTaskRunFactory.build(task=task)
assert_raises(Forbidden, ensure_authorized_to, 'create', taskrun2)
示例2: test_anonymous_user_create_first_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_first_taskrun(self):
"""Test anonymous user can create a taskrun for a given task if he
hasn't already done it"""
task = TaskFactory.create()
taskrun = AnonymousTaskRunFactory.build(task=task)
assert_not_raises(Exception, ensure_authorized_to, 'create', taskrun)
示例3: test_anonymous_user_create_taskrun_non_allow_anonymous_contrib
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_taskrun_non_allow_anonymous_contrib(self):
"""Test anonymous user cannot create a taskrun for a project that does
not allow for anonymous contributors"""
project = ProjectFactory.create(allow_anonymous_contributors=False)
task = TaskFactory.create(project=project)
taskrun = AnonymousTaskRunFactory.build(task=task)
assert_raises(Unauthorized, ensure_authorized_to, 'create', taskrun)
示例4: test_anonymous_user_create_repeated_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_repeated_taskrun(self):
"""Test anonymous user cannot create a taskrun for a task to which
he has previously posted a taskrun"""
task = TaskFactory.create()
taskrun1 = AnonymousTaskRunFactory.create(task=task)
taskrun2 = AnonymousTaskRunFactory.build(task=task)
assert_raises(Forbidden, ensure_authorized_to, 'create', taskrun2)
示例5: test_anonymous_user_create_taskrun_non_allow_anonymous_contrib
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_taskrun_non_allow_anonymous_contrib(self):
"""Test anonymous user cannot create a taskrun for a project that does
not allow for anonymous contributors"""
project = AppFactory.create(allow_anonymous_contributors=False)
task = TaskFactory.create(app=project)
taskrun = AnonymousTaskRunFactory.build(task=task)
assert_raises(Unauthorized, getattr(require, 'taskrun').create, taskrun)
示例6: test_anonymous_user_create_repeated_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_repeated_taskrun(self):
"""Test anonymous user cannot create a taskrun for a task to which
he has previously posted a taskrun"""
with self.flask_app.test_request_context('/'):
task = TaskFactory.create()
taskrun1 = AnonymousTaskRunFactory.create(task=task)
taskrun2 = AnonymousTaskRunFactory.build(task=task)
assert_raises(Forbidden,
getattr(require, 'taskrun').create,
taskrun2)
# But the user can still create taskruns for different tasks
task2 = TaskFactory.create(app=task.app)
taskrun3 = AnonymousTaskRunFactory.build(task=task2)
assert_not_raises(Exception,
getattr(require, 'taskrun').create,
taskrun3)
示例7: test_anonymous_user_create_first_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_first_taskrun(self):
"""Test anonymous user can create a taskrun for a given task if he
hasn't already done it"""
taskrun = AnonymousTaskRunFactory.build()
assert_not_raises(Exception,
getattr(require, 'taskrun').create,
taskrun)
示例8: test_anonymous_user_can_create_taskrun_for_draft_project
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_can_create_taskrun_for_draft_project(self):
"""Test anonymous users can create a taskrun for a project that
is a draft"""
project = ProjectFactory.create(published=False)
task = TaskFactory.create(project=project)
taskrun = AnonymousTaskRunFactory.build(task_id=task.id,
project_id=project.id)
assert_not_raises(Forbidden, ensure_authorized_to, 'create', taskrun)
示例9: test_anonymous_user_create_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_taskrun(self):
"""Test anonymous user can create a taskrun for a task even though
he has posted taskruns for different tasks in the same project"""
tasks = TaskFactory.create_batch(2)
taskrun1 = AnonymousTaskRunFactory.create(task=tasks[0])
taskrun2 = AnonymousTaskRunFactory.build(task_id=tasks[1].id)
assert_not_raises(Exception,
ensure_authorized_to, 'create', taskrun2)
示例10: test_anonymous_user_create_repeated_taskrun
# 需要导入模块: from factories import AnonymousTaskRunFactory [as 别名]
# 或者: from factories.AnonymousTaskRunFactory import build [as 别名]
def test_anonymous_user_create_repeated_taskrun(self):
"""Test anonymous user cannot create a taskrun for a task to which
he has previously posted a taskrun"""
task = TaskFactory.create()
taskrun1 = AnonymousTaskRunFactory.create(task=task)
taskrun2 = AnonymousTaskRunFactory.build(task=task)
assert_raises(Forbidden,
getattr(require, 'taskrun').create,
taskrun2)