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


Python TitleFactory.publish方法代码示例

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


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

示例1: TestWorkflow

# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import publish [as 别名]
class TestWorkflow(TestCase):

    def setUp(self):
        user = UserFactory(username='staff', is_staff=True)
        self.assertTrue(
            self.client.login(username=user.username, password=TEST_PASSWORD)
        )
        self.block = TitleFactory().block

    def _get_pending(self):
        return self.block.content.get(
            moderate_state=ModerateState.objects._pending()
        )

    def _get_published(self):
        return self.block.content.get(
            moderate_state=ModerateState.objects._published()
        )

    def _pending_count(self):
        return self.block.content.filter(
            moderate_state=ModerateState.objects._pending()
        ).count()

    def _publish_count(self):
        return self.block.content.filter(
            moderate_state=ModerateState.objects._published()
        ).count()

    def _remove_count(self):
        return self.block.content.filter(
            moderate_state__slug=ModerateState.REMOVED
        ).count()

    def test_pending(self):
        self.assertEqual(1, self._pending_count())
        self.assertEqual(0, self._publish_count())
        self.assertEqual(0, self._remove_count())

    def test_published(self):
        self.block.publish(UserFactory())
        self.assertEqual(1, self._pending_count())
        self.assertEqual(1, self._publish_count())
        self.assertEqual(0, self._remove_count())

    def test_remove_pending(self):
        self.block.remove(UserFactory())
        self.assertEqual(0, self._pending_count())
        self.assertEqual(0, self._publish_count())
        self.assertEqual(1, self._remove_count())

    def test_remove_published(self):
        self.block.publish(UserFactory())
        self.block.remove(UserFactory())
        self.assertEqual(0, self._pending_count())
        self.assertEqual(0, self._publish_count())
        self.assertEqual(1, self._remove_count())
开发者ID:pkimber,项目名称:block,代码行数:59,代码来源:test_workflow.py


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