當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。