[1201] | 1 | from testQPloneCommentsCommenting import TestCommBase |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | class TestReportAbuse(TestCommBase): |
---|
| 5 | |
---|
| 6 | def afterSetUp(self): |
---|
| 7 | TestCommBase.afterSetUp(self) |
---|
| 8 | self.testAnonymousReportAbuse() |
---|
| 9 | self.testAuthenticatedReportAbuse() |
---|
| 10 | |
---|
| 11 | def testAnonymousReportAbuse(self): |
---|
| 12 | self.login('dm_admin') |
---|
| 13 | doc_obj = getattr(self.portal, "doc_anonym") |
---|
| 14 | discussion = self.discussion.getDiscussionFor(doc_obj) |
---|
| 15 | comment = discussion._container.values()[0] |
---|
| 16 | self.logout() |
---|
| 17 | # Add abuse report on document. |
---|
| 18 | doc_obj.REQUEST.set('comment_id', comment.id) |
---|
| 19 | try: |
---|
[2137] | 20 | doc_obj.report_abuse("Anonymous Report Abuse") |
---|
[1201] | 21 | except: |
---|
[2137] | 22 | raise "Anonymous user CAN'T report abuse in turned ON "\ |
---|
| 23 | "*Anonymous report abuse mode*." |
---|
[1201] | 24 | |
---|
| 25 | def testAuthenticatedReportAbuse(self): |
---|
[2137] | 26 | not_anonym_users = [u for u in self.all_users_id if not u == 'anonym'] |
---|
[1201] | 27 | failed_users = [] |
---|
| 28 | for u in not_anonym_users: |
---|
| 29 | self.login('dm_admin') |
---|
| 30 | doc_id = "doc_%s" % u |
---|
| 31 | doc_obj = getattr(self.portal, doc_id) |
---|
| 32 | discussion = self.discussion.getDiscussionFor(doc_obj) |
---|
| 33 | comment = discussion._container.values()[0] |
---|
| 34 | doc_obj.REQUEST.set('comment_id', comment.id) |
---|
| 35 | self.login(u) |
---|
| 36 | try: |
---|
[2137] | 37 | doc_obj.report_abuse("Anonymous Report Abuse") |
---|
[1201] | 38 | except: |
---|
| 39 | failed_users.append(u) |
---|
| 40 | |
---|
[2137] | 41 | self.assert_(not failed_users, |
---|
| 42 | "%s - user(s) can not report abuse" % failed_users) |
---|
[1201] | 43 | |
---|
| 44 | |
---|
| 45 | def test_suite(): |
---|
| 46 | from unittest import TestSuite, makeSuite |
---|
| 47 | suite = TestSuite() |
---|
| 48 | suite.addTest(makeSuite(TestReportAbuse)) |
---|
| 49 | return suite |
---|