Ejemplo n.º 1
0
 def test_noKarmaForJunk(self):
     # Revisions only associated with junk branches don't get karma,
     # and Lp records that karma_allocated was done.
     author = self.factory.makePerson()
     rev = self.factory.makeRevision(author=author.preferredemail.email)
     branch = self.factory.makePersonalBranch()
     branch.createBranchRevision(1, rev)
     self.assertTrue(rev.karma_allocated)
     self.assertEqual(0, rev.revision_author.person.karma)
     # Nor is this revision identified as needing karma allocated.
     self.assertEqual([],
                      list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 2
0
 def test_noKarmaForJunk(self):
     # Revisions only associated with junk branches don't get karma,
     # and Lp records that karma_allocated was done.
     author = self.factory.makePerson()
     rev = self.factory.makeRevision(
         author=author.preferredemail.email)
     branch = self.factory.makePersonalBranch()
     branch.createBranchRevision(1, rev)
     self.assertTrue(rev.karma_allocated)
     self.assertEqual(0, rev.revision_author.person.karma)
     # Nor is this revision identified as needing karma allocated.
     self.assertEqual(
         [], list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 3
0
 def test_karmaNotAllocatedForKnownAuthorWithInactiveAccount(self):
     # If the revision author is known, but the account is not active,
     # don't allocate karma, and record that karma_allocated was done.
     author = self.factory.makePerson()
     rev = self.factory.makeRevision(author=author.preferredemail.email)
     author.setAccountStatus(AccountStatus.SUSPENDED, None, 'spammer!')
     branch = self.factory.makeProductBranch()
     branch.createBranchRevision(1, rev)
     self.assertTrue(rev.karma_allocated)
     self.assertEqual(0, rev.revision_author.person.karma)
     # Even though the revision author is connected to the person, since
     # the account status is suspended, the person is not "valid", and so
     # the revisions are not returned as needing karma allocated.
     self.assertEqual([],
                      list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 4
0
 def test_karmaNotAllocatedForKnownAuthorWithInactiveAccount(self):
     # If the revision author is known, but the account is not active,
     # don't allocate karma, and record that karma_allocated was done.
     author = self.factory.makePerson()
     rev = self.factory.makeRevision(
         author=author.preferredemail.email)
     author.account.status = AccountStatus.SUSPENDED
     branch = self.factory.makeProductBranch()
     branch.createBranchRevision(1, rev)
     self.assertTrue(rev.karma_allocated)
     self.assertEqual(0, rev.revision_author.person.karma)
     # Even though the revision author is connected to the person, since
     # the account status is suspended, the person is not "valid", and so
     # the revisions are not returned as needing karma allocated.
     self.assertEqual(
         [], list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 5
0
 def test_karmaAllocatedForKnownAuthor(self):
     # If the revision author is known, allocate karma.
     author = self.factory.makePerson()
     rev = self.factory.makeRevision(author=author.preferredemail.email,
                                     revision_date=datetime.now(pytz.UTC) -
                                     timedelta(days=5))
     branch = self.factory.makeProductBranch()
     branch.createBranchRevision(1, rev)
     self.assertTrue(rev.karma_allocated)
     # Get the karma event.
     [karma] = list(
         Store.of(author).find(Karma, Karma.person == author,
                               Karma.product == branch.product))
     self.assertEqual(karma.datecreated, rev.revision_date)
     self.assertEqual(karma.product, branch.product)
     # Since karma has been allocated, the revision isn't in our list.
     self.assertEqual([],
                      list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 6
0
 def test_karmaAllocatedForKnownAuthor(self):
     # If the revision author is known, allocate karma.
     author = self.factory.makePerson()
     rev = self.factory.makeRevision(
         author=author.preferredemail.email,
         revision_date=datetime.now(pytz.UTC) - timedelta(days=5))
     branch = self.factory.makeProductBranch()
     branch.createBranchRevision(1, rev)
     self.assertTrue(rev.karma_allocated)
     # Get the karma event.
     [karma] = list(Store.of(author).find(
         Karma,
         Karma.person == author,
         Karma.product == branch.product))
     self.assertEqual(karma.datecreated, rev.revision_date)
     self.assertEqual(karma.product, branch.product)
     # Since karma has been allocated, the revision isn't in our list.
     self.assertEqual(
         [], list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 7
0
 def test_noRevisionsNeedingAllocation(self):
     # There are no outstanding revisions needing karma allocated.
     self.assertEqual([],
                      list(RevisionSet.getRevisionsNeedingKarmaAllocated()))
Ejemplo n.º 8
0
 def test_noRevisionsNeedingAllocation(self):
     # There are no outstanding revisions needing karma allocated.
     self.assertEqual(
         [], list(RevisionSet.getRevisionsNeedingKarmaAllocated()))