Пример #1
0
  def test_basic(self):
    # membership with a few donors, some progress
    self.create_new()
    ship_id = self.post_id

    # first donor
    donor = models.Donor(membership_id=ship_id, firstname='Alice',
                         amount=240, likelihood=75, talked=True)
    donor.save()
    step = models.Step(donor=donor, date='2015-04-01',
                       description='Talk', completed='2015-04-01')
    step.save()
    step = models.Step(donor=donor, date='2015-5-25', description='Ask')
    step.save()

    # second donor
    donor = models.Donor(membership_id=ship_id, firstname='Bab', talked=True,
                         amount=300, likelihood=50, asked=True,
                         promised=300, received_this=100, received_next=100)
    donor.save()
    step = models.Step(donor=donor, date='2015-04-01',
                       description='Ask', completed='2015-04-01', asked=True)
    step.save()
    step = models.Step(donor=donor, date='2015-04-08',
                       description='Follow upt', completed='2015-04-08',
                       promised=300)
    step.save()
    step = models.Step(donor=donor, date='2015-5-25', description='Thank')
    step.save()

    donors = models.Donor.objects.filter(membership_id=ship_id).prefetch_related('step_set')

    progress, incomplete_steps = _compile_membership_progress(donors)

    self.assertIsInstance(progress, dict)
    self.assertEqual(progress['estimated'], 330)
    self.assertEqual(progress['contacts'], 2)
    self.assertEqual(progress['asked'], 1)
    self.assertEqual(progress['talked'], 1)
    self.assertEqual(progress['promised'], 100)
    self.assertEqual(progress['received'], 200)

    self.assertEqual(progress['contacts_remaining'], 0)
    self.assertEqual(progress['togo'], 30)

    self.assertEqual(len(incomplete_steps), 2)
    for donor in donors:
      self.assertIsInstance(donor.next_step, models.Step)
      self.assertIs(type(donor.completed_steps), list)
      self.assertTrue(len(donor.completed_steps) > 0)
Пример #2
0
    def test_basic(self):
        # membership with a few donors, some progress
        self.login_as_member('new')
        ship_id = self.post_id

        # first donor
        donor = models.Donor(membership_id=ship_id,
                             firstname='Alice',
                             amount=240,
                             likelihood=75,
                             talked=True)
        donor.save()
        step = models.Step(donor=donor,
                           date='2015-04-01',
                           description='Talk',
                           completed='2015-04-01')
        step.save()
        step = models.Step(donor=donor, date='2015-5-25', description='Ask')
        step.save()

        # second donor
        donor = models.Donor(membership_id=ship_id,
                             firstname='Bab',
                             talked=True,
                             amount=300,
                             likelihood=50,
                             asked=True,
                             promised=300,
                             received_this=100,
                             received_next=100)
        donor.save()
        step = models.Step(donor=donor,
                           date='2015-04-01',
                           description='Ask',
                           completed='2015-04-01',
                           asked=True)
        step.save()
        step = models.Step(donor=donor,
                           date='2015-04-08',
                           description='Follow upt',
                           completed='2015-04-08',
                           promised=300)
        step.save()
        step = models.Step(donor=donor, date='2015-5-25', description='Thank')
        step.save()

        donors = models.Donor.objects.filter(
            membership_id=ship_id).prefetch_related('step_set')

        progress, incomplete_steps = _compile_membership_progress(donors)

        self.assertIsInstance(progress, dict)
        self.assertEqual(progress['estimated'], 330)
        self.assertEqual(progress['contacts'], 2)
        self.assertEqual(progress['asked'], 1)
        self.assertEqual(progress['talked'], 1)
        self.assertEqual(progress['promised'], 100)
        self.assertEqual(progress['received'], 200)

        self.assertEqual(progress['contacts_remaining'], 0)
        self.assertEqual(progress['togo'], 30)

        self.assertEqual(len(incomplete_steps), 2)
        for donor in donors:
            self.assertIsInstance(donor.next_step, models.Step)
            self.assertIs(type(donor.completed_steps), list)
            self.assertTrue(len(donor.completed_steps) > 0)
Пример #3
0
    def test_empty(self):
        progress, incomplete_steps = _compile_membership_progress([])

        self.assertEqual(incomplete_steps, [])
        for _, value in progress.iteritems():
            self.assertEqual(value, 0)
Пример #4
0
  def test_empty(self):
    progress, incomplete_steps = _compile_membership_progress([])

    self.assertEqual(incomplete_steps, [])
    for _, value in progress.iteritems():
      self.assertEqual(value, 0)