本文整理汇总了Python中factories.CategoryFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python CategoryFactory.build方法的具体用法?Python CategoryFactory.build怎么用?Python CategoryFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factories.CategoryFactory
的用法示例。
在下文中一共展示了CategoryFactory.build方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_category_fails_if_integrity_error
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import build [as 别名]
def test_save_category_fails_if_integrity_error(self):
"""Test save_category raises a DBIntegrityError if the instance to be
saved lacks a required value"""
category = CategoryFactory.build(name=None)
assert_raises(DBIntegrityError, self.project_repo.save_category, category)
示例2: test_admin_can_crud
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import build [as 别名]
def test_admin_can_crud(self):
"""Test admin user can crud categories"""
category = CategoryFactory.build()
assert_not_raises(Forbidden, ensure_authorized_to, "create", category)
assert_not_raises(Forbidden, ensure_authorized_to, "read", category)
assert_not_raises(Forbidden, ensure_authorized_to, "read", Category)
assert_not_raises(Forbidden, ensure_authorized_to, "update", category)
assert_not_raises(Forbidden, ensure_authorized_to, "delete", category)
示例3: test_authenticated_user_can_crud
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import build [as 别名]
def test_authenticated_user_can_crud(self):
"""Test authenticated users cannot crud categories"""
category = CategoryFactory.build()
assert_raises(Forbidden, ensure_authorized_to, "create", category)
assert_not_raises(Exception, ensure_authorized_to, "read", category)
assert_not_raises(Exception, ensure_authorized_to, "read", Category)
assert_raises(Forbidden, ensure_authorized_to, "update", category)
assert_raises(Forbidden, ensure_authorized_to, "delete", category)
示例4: test_anonymous_user_cannot_crud
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import build [as 别名]
def test_anonymous_user_cannot_crud(self):
"""Test anonymous users cannot crud categories"""
category = CategoryFactory.build()
assert_raises(Unauthorized, ensure_authorized_to, "create", category)
assert_not_raises(Exception, ensure_authorized_to, "read", category)
assert_not_raises(Exception, ensure_authorized_to, "read", Category)
assert_raises(Unauthorized, ensure_authorized_to, "update", category)
assert_raises(Unauthorized, ensure_authorized_to, "delete", category)
示例5: test_save_category
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import build [as 别名]
def test_save_category(self):
"""Test save_category persist the category"""
category = CategoryFactory.build()
assert self.project_repo.get(category.id) is None
self.project_repo.save_category(category)
assert self.project_repo.get_category(category.id) == category, "Category not saved"
示例6: test_default_index
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import build [as 别名]
def test_default_index(self):
"""Tests default index for Category instances"""
c = CategoryFactory.build(name="drought risk")
self.assertEquals(c.index, 1000)