當前位置: 首頁>>代碼示例>>Python>>正文


Python factories.ForumReadTrackFactory類代碼示例

本文整理匯總了Python中machina.test.factories.ForumReadTrackFactory的典型用法代碼示例。如果您正苦於以下問題:Python ForumReadTrackFactory類的具體用法?Python ForumReadTrackFactory怎麽用?Python ForumReadTrackFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ForumReadTrackFactory類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_can_determine_unread_forums

    def test_can_determine_unread_forums(self):
        # Setup
        def get_rendered(topics, user):
            request = self.get_request()
            request.user = user
            ForumPermissionMiddleware().process_request(request)
            t = Template(self.loadstatement + '{% get_unread_topics topics request.user as unread_topics %}')
            c = Context({'topics': topics, 'request': request})
            rendered = t.render(c)

            return c, rendered

        # Run & check
        context, rendered = get_rendered(self.forum_2.topics.all(), self.u2)
        assert rendered == ''
        assert set(context['unread_topics']) == set(self.forum_2.topics.all())

        # forum_2 topics are now read
        TopicReadTrackFactory.create(topic=self.forum_2_topic, user=self.u2)
        context, rendered = get_rendered(self.forum_2.topics.all(), self.u2)
        assert rendered == ''
        assert not len(context['unread_topics'])

        # A new post is created with a pre-existing topic track
        PostFactory.create(topic=self.forum_2_topic, poster=self.u1)
        context, rendered = get_rendered(self.forum_2.topics.all(), self.u2)
        assert rendered == ''
        assert set(context['unread_topics']) == set(self.forum_2.topics.all())

        # A new post is created with a pre-existing forum track
        ForumReadTrackFactory.create(forum=self.forum_1, user=self.u2)
        PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        context, rendered = get_rendered(self.forum_1.topics.all(), self.u2)
        assert rendered == ''
        assert set(context['unread_topics']) == set(self.forum_1.topics.all())
開發者ID:DrJackilD,項目名稱:django-machina,代碼行數:35,代碼來源:test_tracking_tags.py

示例2: setup

    def setup(self):
        # Create a basic user
        self.user = UserFactory.create()

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.cat = create_category_forum()
        self.top_level_forum = create_forum()
        self.other_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(forum=self.top_level_forum, poster=self.user)
        self.first_post = PostFactory.create(topic=self.topic, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_reply_to_topics', self.user, self.top_level_forum)
        assign_perm('can_edit_own_posts', self.user, self.top_level_forum)
        assign_perm('can_delete_own_posts', self.user, self.top_level_forum)
        assign_perm('can_lock_topics', self.user, self.top_level_forum)
開發者ID:harish211,項目名稱:django-machina,代碼行數:26,代碼來源:test_forms.py

示例3: setup

    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(
            forum=self.top_level_forum, poster=self.user,
            status=Topic.TOPIC_LOCKED)
        self.first_post = PostFactory.create(topic=self.topic, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user, approved=False)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_approve_posts', self.user, self.top_level_forum)
開發者ID:ashwin31,項目名稱:django-machina,代碼行數:19,代碼來源:test_views.py

示例4: setup

    def setup(self):
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()

        self.top_level_cat_1 = create_category_forum()
        self.top_level_cat_2 = create_category_forum()

        self.forum_1 = create_forum(parent=self.top_level_cat_1)
        self.forum_2 = create_forum(parent=self.top_level_cat_1)
        self.forum_2_child_1 = create_link_forum(parent=self.forum_2)
        self.forum_2_child_2 = create_forum(parent=self.forum_2)
        self.forum_3 = create_forum(parent=self.top_level_cat_1)

        self.forum_4 = create_forum(parent=self.top_level_cat_2)

        self.topic = create_topic(forum=self.forum_2, poster=self.u1)
        PostFactory.create(topic=self.topic, poster=self.u1)

        # Initially u2 read the previously created topic
        ForumReadTrackFactory.create(forum=self.forum_2, user=self.u2)
開發者ID:DrJackilD,項目名稱:django-machina,代碼行數:20,代碼來源:test_managers.py

示例5: setup

    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(
            forum=self.top_level_forum, poster=self.user,
            status=Topic.STATUS_CHOICES.topic_locked)
        self.first_post = PostFactory.create(topic=self.topic, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_approve_posts', self.user, self.top_level_forum)
開發者ID:harish211,項目名稱:django-machina,代碼行數:20,代碼來源:test_views.py

示例6: setup

    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(forum=self.top_level_forum, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Creates a poll and two options
        self.poll = TopicPollFactory.create(topic=self.topic)
        self.option_1 = TopicPollOptionFactory.create(poll=self.poll)
        self.option_2 = TopicPollOptionFactory.create(poll=self.poll)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_vote_in_polls', self.user, self.top_level_forum)
開發者ID:ellmetha,項目名稱:django-machina,代碼行數:22,代碼來源:test_views.py

示例7: setup

    def setup(self):
        # Add some users
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.g1 = GroupFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)
        self.user.groups.add(self.g1)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Tracking handler
        self.tracks_handler = TrackingHandler()

        self.top_level_cat_1 = create_category_forum()
        self.top_level_cat_2 = create_category_forum()

        self.forum_1 = create_forum(parent=self.top_level_cat_1)
        self.forum_2 = create_forum(parent=self.top_level_cat_1)
        self.forum_2_child_1 = create_forum(parent=self.forum_2)
        self.forum_3 = create_forum(parent=self.top_level_cat_1)

        self.forum_4 = create_forum(parent=self.top_level_cat_2)

        self.topic = create_topic(forum=self.forum_2, poster=self.u1)
        PostFactory.create(topic=self.topic, poster=self.u1)

        # Initially u2 and user read the previously created topic
        ForumReadTrackFactory.create(forum=self.forum_2, user=self.u2)
        ForumReadTrackFactory.create(forum=self.forum_2, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.g1, self.top_level_cat_1)
        assign_perm('can_read_forum', self.g1, self.top_level_cat_2)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_2)
        assign_perm('can_read_forum', self.g1, self.forum_2_child_1)
        assign_perm('can_read_forum', self.g1, self.forum_4)
開發者ID:squamous,項目名稱:django-machina,代碼行數:39,代碼來源:test_views.py

示例8: setup

    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(forum=self.top_level_forum, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Set up an attachment
        f = open(settings.MEDIA_ROOT + '/attachment.jpg', 'rb')
        self.attachment_file = File(f)
        self.attachment = AttachmentFactory.create(
            post=self.post, file=self.attachment_file)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_download_file', self.user, self.top_level_forum)

        yield

        # teardown
        # --

        self.attachment_file.close()
        attachments = Attachment.objects.all()
        for attachment in attachments:
            try:
                attachment.file.delete()
            except:
                pass
開發者ID:ashwin31,項目名稱:django-machina,代碼行數:36,代碼來源:test_views.py


注:本文中的machina.test.factories.ForumReadTrackFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。