示例#1
0
 def test_abuse_already_escalated(self):
     for x in range(2):
         AbuseReport.objects.create(addon=self.app)
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(addon=self.app).count(), 1)
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(addon=self.app).count(), 1)
示例#2
0
 def test_abuse_already_escalated(self):
     for x in range(2):
         AbuseReport.objects.create(addon=self.app)
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(addon=self.app).count(), 1)
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(addon=self.app).count(), 1)
示例#3
0
    def test_already_escalated_for_other_still_logs(self):
        # Add app to queue for high refunds.
        EscalationQueue.objects.create(addon=self.app)
        amo.log(amo.LOG.ESCALATED_HIGH_REFUNDS, self.app, self.app.current_version, details={"comments": "hi refunds"})

        # Set up abuses.
        for x in range(2):
            AbuseReport.objects.create(addon=self.app)
        find_abuse_escalations(self.app.id)

        # Verify it logged the high abuse reports.
        action = amo.LOG.ESCALATED_HIGH_ABUSE
        assert AppLog.objects.filter(
            addon=self.app, activity_log__action=action.id
        ).exists(), u"Expected high abuse to be logged"
示例#4
0
    def test_abuse_cleared_not_escalated(self):
        for x in range(2):
            ar = AbuseReport.objects.create(addon=self.app)
            ar.created = datetime.datetime.now() - datetime.timedelta(days=1)
            ar.save()
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 1)

        # Simulate a reviewer clearing an escalation... remove app from queue,
        # and write a log.
        EscalationQueue.objects.filter(addon=self.app).delete()
        amo.log(amo.LOG.ESCALATION_CLEARED, self.app, self.app.current_version, details={"comments": "All clear"})
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)

        # Task will find it again but not add it again.
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)
示例#5
0
    def test_already_escalated_for_other_still_logs(self):
        # Add app to queue for high refunds.
        EscalationQueue.objects.create(addon=self.app)
        amo.log(amo.LOG.ESCALATED_HIGH_REFUNDS,
                self.app,
                self.app.current_version,
                details={'comments': 'hi refunds'})

        # Set up abuses.
        for x in range(2):
            AbuseReport.objects.create(addon=self.app)
        find_abuse_escalations(self.app.id)

        # Verify it logged the high abuse reports.
        action = amo.LOG.ESCALATED_HIGH_ABUSE
        assert AppLog.objects.filter(
            addon=self.app, activity_log__action=action.id).exists(), (
                u'Expected high abuse to be logged')
示例#6
0
    def test_abuse_cleared_not_escalated(self):
        for x in range(2):
            ar = AbuseReport.objects.create(addon=self.app)
            ar.created = datetime.datetime.now() - datetime.timedelta(days=1)
            ar.save()
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 1)

        # Simulate a reviewer clearing an escalation... remove app from queue,
        # and write a log.
        EscalationQueue.objects.filter(addon=self.app).delete()
        amo.log(amo.LOG.ESCALATION_CLEARED,
                self.app,
                self.app.current_version,
                details={'comments': 'All clear'})
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)

        # Task will find it again but not add it again.
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)
示例#7
0
    def test_older_abuses_cleared_then_new(self):
        for x in range(2):
            ar = AbuseReport.objects.create(webapp=self.app)
            ar.created = datetime.datetime.now() - datetime.timedelta(days=1)
            ar.save()
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(webapp=self.app).count(), 1)

        # Simulate a reviewer clearing an escalation... remove app from queue,
        # and write a log.
        EscalationQueue.objects.filter(webapp=self.app).delete()
        mkt.log(mkt.LOG.ESCALATION_CLEARED, self.app, self.app.current_version,
                details={'comments': 'All clear'})
        eq_(EscalationQueue.objects.filter(webapp=self.app).count(), 0)

        # Task will find it again but not add it again.
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(webapp=self.app).count(), 0)

        # New abuse reports that come in should re-add to queue.
        for x in range(2):
            AbuseReport.objects.create(webapp=self.app)
        find_abuse_escalations(self.app.id)
        eq_(EscalationQueue.objects.filter(webapp=self.app).count(), 1)
示例#8
0
 def test_no_abuses_no_history(self):
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)
示例#9
0
 def test_no_abuses_no_history(self):
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)
示例#10
0
 def test_abuse_no_history(self):
     for x in range(2):
         AbuseReport.objects.create(webapp=self.app)
     find_abuse_escalations(self.app.id)
     eq_(EscalationQueue.objects.filter(webapp=self.app).count(), 1)