Ejemplo n.º 1
0
    def testSendable_DateCollectSendablesAssigned(self):
        c, d, v, a, fix_to_date = self.setup_sendable_test()

        f.TriggerByDateFactory.create_batch(
            3, fixed_date=fix_to_date,
            assignment_state=TriggerBase.ASSIGNED,
            campaign=c)

        result = Sendable.collect_from_fixed_triggers(fix_to_date)
        self.assertEqual(0, result)
        all_qs = Sendable.objects.all()
        self.assertQuerysetEqual(all_qs, [])
Ejemplo n.º 2
0
    def testSendable_DateCollectSendablesAssignable(self):
        c, d, v, a, fix_to_date = self.setup_sendable_test()

        f.TriggerByDateFactory.create_batch(
            3, fixed_date=fix_to_date,
            assignment_state=TriggerBase.ASSIGNABLE, campaign=c)

        result = Sendable.collect_from_fixed_triggers(fix_to_date)
        self.assertEqual(3, result)
        all_qs = Sendable.objects.all().order_by('id')
        self.assertQuerysetEqual(all_qs, [v, v, v],
                                 transform=lambda s: s.volunteer)
Ejemplo n.º 3
0
    def testSendable_DateCollectSendablesAssignableButAlreadyAssigned(self):
        c, d, v, a, fix_to_date = self.setup_sendable_test()

        f.AssignmentFactory(volunteer=v, duty=d)

        f.TriggerByDateFactory.create(
            fixed_date=fix_to_date,
            assignment_state=TriggerBase.ASSIGNABLE,
            campaign=c)

        result = Sendable.collect_from_fixed_triggers(fix_to_date)
        self.assertEqual(0, result)
        all_qs = Sendable.objects.all()
        self.assertQuerysetEqual(all_qs, [])
Ejemplo n.º 4
0
    def testSendable_DateCollectSendablesAssignableButEventNotVisible(self):
        c, d, v, a, fix_to_date = self.setup_sendable_test()

        d.event.is_visible_to_volunteers = False
        d.event.save()

        f.TriggerByDateFactory.create_batch(
            3, fixed_date=fix_to_date,
            assignment_state=TriggerBase.ASSIGNABLE, campaign=c)

        result = Sendable.collect_from_fixed_triggers(fix_to_date)
        self.assertEqual(0, result)
        all_qs = Sendable.objects.all()
        self.assertQuerysetEqual(all_qs, [])
 def testSendable_DateCollectSendablesAssigned(self):
     fix_to_date = date(2005, 5, 5)
     c = f.CampaignFactory()
     d = f.FullDutyFactory()
     c.events.add(d.event)
     v = f.VolunteerFactory()
     a = f.AttributeFactory()
     v.attributes.add(a)
     d.activity.attributes.add(a)
     f.TriggerByDateFactory.create_batch(
         3, fixed_date=fix_to_date,
         assignment_state=TriggerBase.ASSIGNED,
         campaign=c)
     result = Sendable.collect_from_fixed_triggers(fix_to_date)
     self.assertEqual(0, result)
     all_qs = Sendable.objects.all()
     self.assertQuerysetEqual(all_qs, [])
Ejemplo n.º 6
0
    def testSendable_DateCollectSndblesUnassignedButAssignedOnce(self):
        c, d, v, a, fix_to_date = self.setup_sendable_test()

        d2 = f.FullDutyFactory.create()
        c.events.add(d2.event)
        v2, _ = f.VolunteerFactory.create_batch(2)
        v2.attributes.add(a)
        d2.activity.attributes.add(a)

        f.AssignmentFactory(volunteer=v, duty=d)

        f.TriggerByDateFactory.create(
            fixed_date=fix_to_date,
            assignment_state=TriggerBase.UNASSIGNED,
            campaign=c)

        result = Sendable.collect_from_fixed_triggers(fix_to_date)
        self.assertEqual(1, result)
        all_qs = Sendable.objects.all()
        self.assertQuerysetEqual(all_qs, [v2],
                                 transform=lambda s: s.volunteer)