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


Python BlogpostFactory.build方法代码示例

本文整理汇总了Python中factories.BlogpostFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python BlogpostFactory.build方法的具体用法?Python BlogpostFactory.build怎么用?Python BlogpostFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在factories.BlogpostFactory的用法示例。


在下文中一共展示了BlogpostFactory.build方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_anonymous_user_create_given_blogpost

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_anonymous_user_create_given_blogpost(self):
        """Test anonymous users cannot create a given blogpost"""

        app = AppFactory.create()
        blogpost = BlogpostFactory.build(app=app, owner=None)

        assert_raises(Unauthorized, getattr(require, 'blogpost').create, blogpost)
开发者ID:alisheikh,项目名称:pybossa,代码行数:9,代码来源:test_blogpost_auth.py

示例2: test_save_fails_if_integrity_error

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_save_fails_if_integrity_error(self):
        """Test save raises a DBIntegrityError if the instance to be saved lacks
        a required value"""

        blogpost = BlogpostFactory.build(title=None)

        assert_raises(DBIntegrityError, self.blog_repo.save, blogpost)
开发者ID:PyBossa,项目名称:pybossa,代码行数:9,代码来源:test_blog_repository.py

示例3: test_anonymous_user_create_given_blogpost

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_anonymous_user_create_given_blogpost(self):
        """Test anonymous users cannot create a given blogpost"""

        project = ProjectFactory.create()
        blogpost = BlogpostFactory.build(project=project, owner=None)

        assert_raises(Unauthorized, ensure_authorized_to, 'create', blogpost)
开发者ID:anukat2015,项目名称:pybossa,代码行数:9,代码来源:test_blogpost_auth.py

示例4: test_save

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_save(self):
        """Test save persist the blogpost"""

        blogpost = BlogpostFactory.build()
        assert self.blog_repo.get(blogpost.id) is None

        self.blog_repo.save(blogpost)

        assert self.blog_repo.get(blogpost.id) == blogpost, "Blogpost not saved"
开发者ID:Skytim,项目名称:pybossa,代码行数:11,代码来源:test_blog_repository.py

示例5: test_owner_create_given_blogpost

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_owner_create_given_blogpost(self):
        """Test authenticated user can create a given blogpost if is project owner"""

        owner = UserFactory.create_batch(2)[1]
        app = AppFactory.create(owner=owner)
        blogpost = BlogpostFactory.build(app=app, owner=owner)

        assert self.mock_authenticated.id == app.owner_id
        assert_not_raises(Exception, getattr(require, 'blogpost').create, blogpost)
开发者ID:alisheikh,项目名称:pybossa,代码行数:11,代码来源:test_blogpost_auth.py

示例6: test_owner_create_given_blogpost

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_owner_create_given_blogpost(self):
        """Test authenticated user can create a given blogpost if is project owner"""

        owner = UserFactory.create_batch(2)[1]
        project = ProjectFactory.create(owner=owner)
        blogpost = BlogpostFactory.build(project=project, owner=owner)

        assert self.mock_authenticated.id == project.owner_id
        assert_not_raises(Exception, ensure_authorized_to, 'create', blogpost)
开发者ID:anukat2015,项目名称:pybossa,代码行数:11,代码来源:test_blogpost_auth.py

示例7: test_save

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_save(self, clean_project_mock):
        """Test save persist the blogpost"""

        blogpost = BlogpostFactory.build()
        assert self.blog_repo.get(blogpost.id) is None

        self.blog_repo.save(blogpost)

        assert self.blog_repo.get(blogpost.id) == blogpost, "Blogpost not saved"
        clean_project_mock.assert_called_with(blogpost.project_id)
开发者ID:PyBossa,项目名称:pybossa,代码行数:12,代码来源:test_blog_repository.py

示例8: test_non_owner_authenticated_user_create_given_blogpost

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_non_owner_authenticated_user_create_given_blogpost(self):
        """Test authenticated user cannot create a given blogpost if is not the
        project owner, even if is admin"""

        admin = UserFactory.create()
        app = AppFactory.create()
        blogpost = BlogpostFactory.build(app=app, owner=admin)

        assert self.mock_admin.id != app.owner_id
        assert_raises(Forbidden, getattr(require, 'blogpost').create, blogpost)
开发者ID:alisheikh,项目名称:pybossa,代码行数:12,代码来源:test_blogpost_auth.py

示例9: test_non_owner_authenticated_user_create_given_blogpost

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_non_owner_authenticated_user_create_given_blogpost(self):
        """Test authenticated user cannot create a given blogpost if is not the
        project owner, even if is admin"""

        admin = UserFactory.create()
        project = ProjectFactory.create()
        blogpost = BlogpostFactory.build(project=project, owner=admin)

        assert self.mock_admin.id != project.owner_id
        assert_raises(Forbidden, ensure_authorized_to, 'create', blogpost)
开发者ID:anukat2015,项目名称:pybossa,代码行数:12,代码来源:test_blogpost_auth.py

示例10: test_owner_create_blogpost_as_other_user

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_owner_create_blogpost_as_other_user(self):
        """Test authenticated user cannot create blogpost if is project owner but
        sets another person as the author of the blogpost"""

        another_user = UserFactory.create()
        app = AppFactory.create()
        blogpost = BlogpostFactory.build(app_id=app.id,
                                          owner=another_user)

        assert self.mock_authenticated.id == app.owner_id
        assert_raises(Forbidden, getattr(require, 'blogpost').create, blogpost)
开发者ID:alisheikh,项目名称:pybossa,代码行数:13,代码来源:test_blogpost_auth.py

示例11: test_owner_create_blogpost_as_other_user

# 需要导入模块: from factories import BlogpostFactory [as 别名]
# 或者: from factories.BlogpostFactory import build [as 别名]
    def test_owner_create_blogpost_as_other_user(self):
        """Test authenticated user cannot create blogpost if is project owner but
        sets another person as the author of the blogpost"""

        another_user = UserFactory.create()
        project = ProjectFactory.create()
        blogpost = BlogpostFactory.build(project_id=project.id,
                                          owner=another_user)

        assert self.mock_authenticated.id == project.owner_id
        assert_raises(Forbidden, ensure_authorized_to, 'create', blogpost)
开发者ID:anukat2015,项目名称:pybossa,代码行数:13,代码来源:test_blogpost_auth.py


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