traversal test for the replies adapter added.
svn path=/plone.app.discussion/trunk/; revision=27459
This commit is contained in:
		
							parent
							
								
									886fe17b47
								
							
						
					
					
						commit
						baeb3a638c
					
				@ -201,5 +201,56 @@ class RepliesTest(PloneTestCase):
 | 
				
			|||||||
        # Make sure the first comment is still in the conversation
 | 
					        # Make sure the first comment is still in the conversation
 | 
				
			||||||
        self.assertEquals(conversation.total_comments, 1)
 | 
					        self.assertEquals(conversation.total_comments, 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_traversal(self):
 | 
				
			||||||
 | 
					        # Create a nested structure of comment replies and check the traversal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # make sure comments are traversable, have an id, absolute_url and physical path
 | 
				
			||||||
 | 
					        conversation = IConversation(self.portal.doc1).__of__(self.portal.doc1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        comment1 = createObject('plone.Comment')
 | 
				
			||||||
 | 
					        comment1.title = 'Comment 1'
 | 
				
			||||||
 | 
					        comment1.text = 'Comment text'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        new_comment1_id = conversation.addComment(comment1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        comment = createObject('plone.Comment')
 | 
				
			||||||
 | 
					        comment.title = 'Comment 1'
 | 
				
			||||||
 | 
					        comment.text = 'Comment text'
 | 
				
			||||||
 | 
					        new_id = conversation.addComment(comment)
 | 
				
			||||||
 | 
					        comment = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Add a reply to the CommentReplies adapter of the first comment
 | 
				
			||||||
 | 
					        re_comment = createObject('plone.Comment')
 | 
				
			||||||
 | 
					        re_comment.title = 'Re: Comment 1'
 | 
				
			||||||
 | 
					        re_comment.text = 'Comment text'
 | 
				
			||||||
 | 
					        replies = IReplies(comment)
 | 
				
			||||||
 | 
					        new_re_id = replies.addComment(re_comment)
 | 
				
			||||||
 | 
					        re_comment = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_re_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Add a reply to the reply
 | 
				
			||||||
 | 
					        re_re_comment = createObject('plone.Comment')
 | 
				
			||||||
 | 
					        re_re_comment.title = 'Re: Re: Comment 1'
 | 
				
			||||||
 | 
					        re_re_comment.text = 'Comment text'
 | 
				
			||||||
 | 
					        replies = IReplies(re_comment)
 | 
				
			||||||
 | 
					        new_re_re_id = replies.addComment(re_re_comment)
 | 
				
			||||||
 | 
					        re_re_comment = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_re_re_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Add a reply to the replies reply
 | 
				
			||||||
 | 
					        re_re_re_comment = createObject('plone.Comment')
 | 
				
			||||||
 | 
					        re_re_re_comment.title = 'Re: Re: Comment 1'
 | 
				
			||||||
 | 
					        re_re_re_comment.text = 'Comment text'
 | 
				
			||||||
 | 
					        replies = IReplies(re_re_comment)
 | 
				
			||||||
 | 
					        new_re_re_re_id = replies.addComment(re_re_re_comment)
 | 
				
			||||||
 | 
					        re_re_re_comment = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_re_re_re_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.assertEquals(('', 'plone', 'doc1', '++conversation++default', str(new_id)), comment.getPhysicalPath())
 | 
				
			||||||
 | 
					        self.assertEquals('http://nohost/plone/doc1/++conversation++default/' + str(new_id), comment.absolute_url())
 | 
				
			||||||
 | 
					        self.assertEquals(('', 'plone', 'doc1', '++conversation++default', str(new_re_id)), re_comment.getPhysicalPath())
 | 
				
			||||||
 | 
					        self.assertEquals('http://nohost/plone/doc1/++conversation++default/' + str(new_re_id), re_comment.absolute_url())
 | 
				
			||||||
 | 
					        self.assertEquals(('', 'plone', 'doc1', '++conversation++default', str(new_re_re_id)), re_re_comment.getPhysicalPath())
 | 
				
			||||||
 | 
					        self.assertEquals('http://nohost/plone/doc1/++conversation++default/' + str(new_re_re_id), re_re_comment.absolute_url())
 | 
				
			||||||
 | 
					        self.assertEquals(('', 'plone', 'doc1', '++conversation++default', str(new_re_re_re_id)), re_re_re_comment.getPhysicalPath())
 | 
				
			||||||
 | 
					        self.assertEquals('http://nohost/plone/doc1/++conversation++default/' + str(new_re_re_re_id), re_re_re_comment.absolute_url())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_suite():
 | 
					def test_suite():
 | 
				
			||||||
    return unittest.defaultTestLoader.loadTestsFromName(__name__)
 | 
					    return unittest.defaultTestLoader.loadTestsFromName(__name__)
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user