Beispiel #1
0
    def test_recent_spam_revisions_show(self, mock_analytics_upageviews):
        """The correct spam revisions should show up."""
        doc1 = create_document(save=True)
        doc2 = create_document(save=True)
        # Create some revisions by self.testuser
        rev_doc0 = self.create_revisions(num=1,
                                         creator=self.testuser,
                                         document=self.document)
        rev_doc1 = self.create_revisions(num=1,
                                         creator=self.testuser,
                                         document=doc1)
        rev_doc2 = self.create_revisions(num=1,
                                         creator=self.testuser,
                                         document=doc2)
        created_revisions = rev_doc0 + rev_doc1 + rev_doc2
        # Mark each revision as created yesterday
        for rev in created_revisions:
            rev.created = datetime.datetime.today() - datetime.timedelta(
                days=1)
            rev.save()
        # Mark each of self.testuser's revisions as spam
        for revision in created_revisions:
            revision.akismet_submissions.create(sender=self.admin, type="spam")
        # self.admin creates some revisions on a different document
        self.create_revisions(num=3, creator=self.admin)

        mock_analytics_upageviews.return_value = {
            rev_doc0[0].id: 0,
            rev_doc1[0].id: 0,
            rev_doc2[0].id: 0
        }

        self.client.login(username='******', password='******')
        # The first response will say that the report is being processed
        response = self.client.get(reverse('dashboards.spam'),
                                   HTTP_HOST=settings.WIKI_HOST)
        assert 200 == response.status_code

        response2 = self.client.get(reverse('dashboards.spam'),
                                    HTTP_HOST=settings.WIKI_HOST)
        page = pq(response2.content)
        table_rows = page.find('.spam-events-table tbody tr')
        table_row_text = ''
        for table_row in table_rows:
            table_row_text += table_row.text_content()

        assert len(table_rows) == len(created_revisions)
        for revision in created_revisions:
            document_url = reverse(
                'wiki.document',
                kwargs={'document_path': revision.document.slug})
            assert document_url in table_row_text
Beispiel #2
0
    def test_recent_spam_revisions_show(self, mock_analytics_upageviews):
        """The correct spam revisions should show up."""
        doc1 = create_document(save=True)
        doc2 = create_document(save=True)
        # Create some revisions by self.testuser
        rev_doc0 = self.create_revisions(
            num=1,
            creator=self.testuser,
            document=self.document
        )
        rev_doc1 = self.create_revisions(num=1, creator=self.testuser, document=doc1)
        rev_doc2 = self.create_revisions(num=1, creator=self.testuser, document=doc2)
        created_revisions = rev_doc0 + rev_doc1 + rev_doc2
        # Mark each revision as created yesterday
        for rev in created_revisions:
            rev.created = datetime.datetime.today() - datetime.timedelta(days=1)
            rev.save()
        # Mark each of self.testuser's revisions as spam
        for revision in created_revisions:
            revision.akismet_submissions.add(RevisionAkismetSubmission(
                sender=self.admin, type="spam")
            )
        # self.admin creates some revisions on a different document
        self.create_revisions(num=3, creator=self.admin)

        mock_analytics_upageviews.return_value = {
            rev_doc0[0].id: 0,
            rev_doc1[0].id: 0,
            rev_doc2[0].id: 0
        }

        self.client.login(username='******', password='******')
        # The first response will say that the report is being processed
        response = self.client.get(reverse('dashboards.spam', locale='en-US'))
        eq_(200, response.status_code)

        response2 = self.client.get(reverse('dashboards.spam', locale='en-US'))
        page = pq(response2.content)
        table_rows = page.find('.spam-events-table tbody tr')
        table_row_text = ''
        for table_row in table_rows:
            table_row_text += table_row.text_content()

        eq_(len(table_rows), len(created_revisions))
        for revision in created_revisions:
            document_url = reverse(
                'wiki.document',
                kwargs={'document_path': revision.document.slug}
            )
            ok_(document_url in table_row_text)