Exemple #1
0
    def test_view(self):
        # make sure that the comment view is there and redirects to the right
        # URL

        # Create a conversation. In this case we doesn't assign it to an
        # object, as we just want to check the Conversation object API.
        conversation = IConversation(self.portal.doc1)

        # Create a comment
        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment text'

        # Add comment to the conversation
        new_comment1_id = conversation.addComment(comment1)

        comment = self.portal.doc1.restrictedTraverse(
            '++conversation++default/{0}'.format(new_comment1_id)
        )

        # make sure the view is there
        self.assertTrue(getMultiAdapter((comment, self.request),
                                        name='view'))

        # make sure the HTTP redirect (status code 302) works when a comment
        # is called directly
        view = View(comment, self.request)
        View.__call__(view)
        self.assertEqual(self.request.response.status, 302)
    def test_view(self):
        # make sure that the comment view is there and redirects to the right
        # URL

        # Create a conversation. In this case we doesn't assign it to an
        # object, as we just want to check the Conversation object API.
        conversation = IConversation(self.portal.doc1)

        # Create a comment
        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment text'

        # Add comment to the conversation
        new_comment1_id = conversation.addComment(comment1)

        comment = self.portal.doc1.restrictedTraverse(
            '++conversation++default/{0}'.format(new_comment1_id), )

        # make sure the view is there
        self.assertTrue(
            getMultiAdapter(
                (comment, self.request),
                name='view',
            ), )

        # make sure the HTTP redirect (status code 302) works when a comment
        # is called directly
        view = View(comment, self.request)
        View.__call__(view)
        self.assertEqual(self.request.response.status, 302)
    def test_view_blob_types(self):
        """
        Make sure that traversal to images/files redirects to the
        version of the url with a /view in it.
        """
        self.portal.invokeFactory(id='image1',
                                  title='Image',
                                  type_name='Image')
        conversation = IConversation(self.portal.image1)

        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment text'
        new_comment1_id = conversation.addComment(comment1)
        comment = self.portal.image1.restrictedTraverse(
            '++conversation++default/%s' % new_comment1_id)

        view = View(comment, self.request)
        View.__call__(view)
        response = self.request.response
        self.assertIn("/view", response.headers['location'])
    def test_view_blob_types(self):
        """
        Make sure that traversal to images/files redirects to the
        version of the url with a /view in it.
        """
        self.portal.invokeFactory(id='image1',
                          title='Image',
                          type_name='Image')
        conversation = IConversation(self.portal.image1)

        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment text'
        new_comment1_id = conversation.addComment(comment1)
        comment = self.portal.image1.restrictedTraverse(
            '++conversation++default/%s' % new_comment1_id)

        view = View(comment, self.request)
        View.__call__(view)
        response = self.request.response
        self.assertIn("/view", response.headers['location'])