1 | # |
---|
2 | # Tests sending of notification mails |
---|
3 | # |
---|
4 | |
---|
5 | import os, sys |
---|
6 | if __name__ == '__main__': |
---|
7 | execfile(os.path.join(sys.path[0], 'framework.py')) |
---|
8 | |
---|
9 | from Products.PloneTestCase import PloneTestCase |
---|
10 | from AccessControl.SecurityManagement import newSecurityManager |
---|
11 | from helperNotify import * |
---|
12 | |
---|
13 | PRODUCT = 'qPloneComments' |
---|
14 | PROPERTY_SHEET = "qPloneComments" |
---|
15 | |
---|
16 | PloneTestCase.installProduct(PRODUCT) |
---|
17 | PloneTestCase.setupPloneSite() |
---|
18 | |
---|
19 | |
---|
20 | class TestNotificationMailsSend(PloneTestCase.FunctionalTestCase): |
---|
21 | |
---|
22 | def afterSetUp(self): |
---|
23 | self.loginAsPortalOwner() |
---|
24 | self.addProduct(PRODUCT) |
---|
25 | self.basic_auth = 'membr:secret' |
---|
26 | |
---|
27 | '''Preparation for functional testing''' |
---|
28 | self.discussion = self.portal.portal_discussion |
---|
29 | |
---|
30 | # Allow discussion for Document |
---|
31 | self.portal.portal_types.getTypeInfo('Document')._updateProperty('allow_discussion', 1) |
---|
32 | |
---|
33 | # Add testing document to portal |
---|
34 | self.portal.invokeFactory('Document', id='my_doc') |
---|
35 | self.my_doc = self.portal['my_doc'] |
---|
36 | self.my_doc.edit(text_format='plain', text='hello world') |
---|
37 | self.absolute_url = self.my_doc.absolute_url_path() |
---|
38 | |
---|
39 | prepareMailSendTest() |
---|
40 | self.logout() |
---|
41 | |
---|
42 | def testMemberAddComment(self): |
---|
43 | # Add new Member |
---|
44 | self.portal.portal_membership.addMember('membr', 'secret' , ['Member'], []) |
---|
45 | self.login(name='membr') |
---|
46 | user = self.portal.portal_membership.getAuthenticatedMember() |
---|
47 | user.setMemberProperties({'email':'comentar@test.com'}) |
---|
48 | email = user.getProperty(id = 'email') |
---|
49 | |
---|
50 | # Create talkback for document and add comment |
---|
51 | talkback = self.discussion.getDiscussionFor(self.my_doc) |
---|
52 | talkback.createReply( title='test', text='blah' ) |
---|
53 | |
---|
54 | # Publish comment after moderation |
---|
55 | path = '%s/prefs_recent_comments_form?form.submitted=1'%self.absolute_url |
---|
56 | extra = {'ids' : ['test']} |
---|
57 | self.publish(path, self.basic_auth, extra=extra) |
---|
58 | result = getFileContent(output_file_path('mail.res')) |
---|
59 | verifyMail(result, 'submit') |
---|
60 | |
---|
61 | |
---|
62 | def testMemberReplyComment(self): |
---|
63 | # Add new Member |
---|
64 | self.portal.portal_membership.addMember('membr', 'secret' , ['Member'], []) |
---|
65 | self.login(name='membr') |
---|
66 | user = self.portal.portal_membership.getAuthenticatedMember() |
---|
67 | user.setMemberProperties({'email':'comentar@test.com'}) |
---|
68 | email = user.getProperty(id = 'email') |
---|
69 | |
---|
70 | # Create talkback for document add comment and reply for comment |
---|
71 | talkback = self.discussion.getDiscussionFor(self.my_doc) |
---|
72 | reply_id = talkback.createReply( title='test1', text='blah' ) |
---|
73 | self.loginAsPortalOwner() |
---|
74 | reply1 = talkback.getReplies()[0] |
---|
75 | talkback1 = self.discussion.getDiscussionFor(reply1) |
---|
76 | talkback1.createReply( title='test2', text='blah2') |
---|
77 | |
---|
78 | # Publish comment after moderation |
---|
79 | path = '%s/prefs_recent_comments_form?form.submitted=1'%self.absolute_url |
---|
80 | extra = {'ids' : ['test2']} |
---|
81 | self.publish(path, self.basic_auth, extra=extra) |
---|
82 | result = getFileContent(output_file_path('mail.res')) |
---|
83 | verifyMail(result, 'reply') |
---|
84 | |
---|
85 | def testAnonymAddCommentWithEmail(self): |
---|
86 | self.logout() |
---|
87 | |
---|
88 | def testAnonymReplyCommentWithEmail(self): |
---|
89 | self.logout() |
---|
90 | |
---|
91 | def testAnonymAddCommentWithoutEmail(self): |
---|
92 | self.logout() |
---|
93 | |
---|
94 | def testAnonymReplyCommentWithoutEmail(self): |
---|
95 | self.logout() |
---|
96 | |
---|
97 | |
---|
98 | def test_suite(): |
---|
99 | from unittest import TestSuite, makeSuite |
---|
100 | suite = TestSuite() |
---|
101 | suite.addTest(makeSuite(TestNotificationMailsSend)) |
---|
102 | return suite |
---|
103 | |
---|
104 | if __name__ == '__main__': |
---|
105 | framework() |
---|