Fix some security issues and make the traversal adapter work with OFS.Traversable. Requires a name, so we now call it ++conversation++default
svn path=/plone.app.discussion/trunk/; revision=27059
This commit is contained in:
@@ -6,7 +6,6 @@ from Products.PloneTestCase.ptc import PloneTestCase
|
||||
from plone.app.discussion.tests.layer import DiscussionLayer
|
||||
|
||||
from plone.app.discussion.interfaces import IComment, IConversation
|
||||
from plone.app.discussion.comment import Comment
|
||||
|
||||
class CommentTest(PloneTestCase):
|
||||
|
||||
@@ -19,30 +18,44 @@ class CommentTest(PloneTestCase):
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
|
||||
def test_factory(self):
|
||||
# test with createObject()
|
||||
pass
|
||||
comment1 = createObject('plone.Comment')
|
||||
self.assert_(IComment.providedBy(comment1))
|
||||
|
||||
def test_id(self):
|
||||
# relationship between id, getId(), __name__
|
||||
pass
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.comment_id = 123
|
||||
self.assertEquals('123', comment1.id)
|
||||
self.assertEquals('123', comment1.getId())
|
||||
self.assertEquals(u'123', comment1.__name__)
|
||||
|
||||
def test_title(self):
|
||||
pass
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.title = "New title"
|
||||
self.assertEquals("New title", comment1.Title())
|
||||
|
||||
def test_creator(self):
|
||||
pass
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.creator = "Jim"
|
||||
self.assertEquals("Jim", comment1.Creator())
|
||||
|
||||
def test_traversal(self):
|
||||
# make sure comments are traversable, have an id, absolute_url and physical path
|
||||
|
||||
# XXX - traversal doesn't work without a name?
|
||||
conversation = self.portal.doc1.restrictedTraverse('++comment++1')
|
||||
self.assert_(IConversation.providedBy(conversation))
|
||||
conversation = IConversation(self.portal.doc1).__of__(self.portal.doc1)
|
||||
|
||||
# TODO: Test adding comments, traversing to them
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.title = 'Comment 1'
|
||||
comment1.text = 'Comment text'
|
||||
|
||||
new_comment1_id = conversation.addComment(comment1)
|
||||
|
||||
comment = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_comment1_id)
|
||||
self.assert_(IComment.providedBy(comment))
|
||||
self.assertEquals('Comment 1', comment.title)
|
||||
|
||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default', str(new_comment1_id)), comment.getPhysicalPath())
|
||||
self.assertEquals('plone/doc1/%2B%2Bconversation%2B%2Bdefault/' + str(new_comment1_id), comment.absolute_url())
|
||||
|
||||
pass
|
||||
|
||||
def test_workflow(self):
|
||||
# ensure that we can assign a workflow to the comment type and perform
|
||||
# workflow operations
|
||||
|
||||
@@ -47,7 +47,7 @@ class ConversationTest(PloneTestCase):
|
||||
self.assertEquals(conversation.total_comments, 1)
|
||||
self.assert_(conversation.last_comment_date - datetime.now() < timedelta(seconds=1))
|
||||
|
||||
def test_delete(self):
|
||||
def test_delete_comment(self):
|
||||
pass
|
||||
|
||||
def test_dict_operations(self):
|
||||
@@ -103,6 +103,15 @@ class ConversationTest(PloneTestCase):
|
||||
|
||||
def test_get_threads_batched(self):
|
||||
pass
|
||||
|
||||
def test_traversal(self):
|
||||
# make sure we can traverse to conversations and get a URL and path
|
||||
|
||||
conversation = self.portal.doc1.restrictedTraverse('++conversation++default')
|
||||
self.assert_(IConversation.providedBy(conversation))
|
||||
|
||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default'), conversation.getPhysicalPath())
|
||||
self.assertEquals('plone/doc1/%2B%2Bconversation%2B%2Bdefault', conversation.absolute_url())
|
||||
|
||||
class RepliesTest(PloneTestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user