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


Python CategoryFactory.build方法代码示例

本文整理汇总了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)
开发者ID:anukat2015,项目名称:pybossa,代码行数:9,代码来源:test_project_repository.py

示例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)
开发者ID:chandra1b,项目名称:pybossa,代码行数:11,代码来源:test_category_auth.py

示例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)
开发者ID:chandra1b,项目名称:pybossa,代码行数:11,代码来源:test_category_auth.py

示例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)
开发者ID:chandra1b,项目名称:pybossa,代码行数:11,代码来源:test_category_auth.py

示例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"
开发者ID:anukat2015,项目名称:pybossa,代码行数:11,代码来源:test_project_repository.py

示例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)
开发者ID:dsandoval,项目名称:lizard-maptree,代码行数:6,代码来源:models.py


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