Exemple #1
0
    def test_queryset_for_new_group_rule_for_last_donation_is_after(self):
        # create a new group rule
        group, group_rule = self.test_create_new_group_rule_for_last_donation_is_after()

        # hand-create a few people, some of whom match, and others who don't
        ppl = self._generate_people()
        target_date = datetime.date(month=2,day=12,year=2009)
        Factory.donation(ppl[1], date=target_date+datetime.timedelta(days=10))
        Factory.donation(ppl[2], date=target_date)
        Factory.donation(ppl[4], date=target_date-datetime.timedelta(days=59))

        self.assertEqual(group_rule.queryset_filter_string, "filter(donor__donation__date__gt=datetime.date(month=2,day=12,year=2009))")

        # get the queryset, make sure it matches a hand-created one.
        qs = group.members
    
        hand_qs = Person.objects_by_account(self.account).filter(Q(pk=ppl[1].pk))
        self.assertEqualQuerySets(qs,hand_qs)

        # check the opposite
        opposite_group, opposite_group_rule = self.test_create_new_group_rule_for_last_donation_is_after(operator_name="is before")
        oppostite_hand_qs = Person.objects_by_account(self.account).filter(Q(pk=ppl[4].pk))
        self.assertEqualQuerySets(opposite_group.members,oppostite_hand_qs)
Exemple #2
0
 def test_challenge_has_added_a_donation(self):
     Factory.donation(account=self.a1)
     self.a1.check_challenge_progress()
     assert self.a1.challenge_has_added_a_donation == True