コード例 #1
0
 def testSingleEntry(self):
     donor = randgen.generate_donor(self.rand)
     donor.save()
     prize = randgen.generate_prize(self.rand, event=self.event)
     prize.save()
     entry = models.DonorPrizeEntry(donor=donor, prize=prize)
     entry.save()
     eligible = prize.eligible_donors()
     self.assertEqual(1, len(eligible))
     self.assertEqual(donor.pk, eligible[0]['donor'])
     self.assertEqual(entry.weight, eligible[0]['weight'])
コード例 #2
0
 def testMultipleEntries(self):
     numDonors = 5
     donors = []
     prize = randgen.generate_prize(self.rand, event=self.event)
     prize.save()
     for i in range(0, numDonors):
         donor = randgen.generate_donor(self.rand)
         donor.save()
         entry = models.DonorPrizeEntry(donor=donor, prize=prize)
         entry.save()
         donors.append(donor.pk)
     eligible = prize.eligible_donors()
     self.assertEqual(numDonors, len(eligible))
     for donorId in map(lambda x: x['donor'], eligible):
         self.assertTrue(donorId in donors)