Exemplo n.º 1
0
 def test_no_promise(self):
     donor = Donor(membership_id=self.pre_id,
                   firstname='Hello',
                   amount=20,
                   likelihood=75)
     donor.save()
     self.assertEqual(donor.total_promised(), 0)
Exemplo n.º 2
0
    def test_valid_pre(self):
        self.login_as_member('new')
        donor = Donor(membership_id=self.pre_id, firstname='Maebe')
        donor.save()

        res = self.client.post(self._get_url(donor.pk), self.form_data)

        self.assertEqual(res.content, 'success')
Exemplo n.º 3
0
 def setUp(self):
     super(AddStep, self).setUp()
     self.login_as_member('new')
     donor = Donor(firstname='user', lastname='', membership_id=self.pre_id)
     donor.save()
     self.donor_id = donor.pk
     self.url = reverse('sjfnw.fund.views.add_step',
                        kwargs={'donor_id': donor.pk})
     self.valid_form = {'date': '11/13/2034', 'description': 'Talk to them'}
Exemplo n.º 4
0
  def test_get_over_ten(self):
    for i in range(1, 11):
      donor = Donor(firstname='Person{}'.format(i), membership_id=self.ship_id)
      donor.save()

    res = self.client.get(self.url)

    self.assertEqual(res.status_code, 200)
    self.assertEqual(res.context['size'], 10)
Exemplo n.º 5
0
    def test_get_over_ten(self):
        for i in range(1, 11):
            donor = Donor(firstname='Person{}'.format(i),
                          membership_id=self.ship_id)
            donor.save()

        res = self.client.get(self.url)

        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.context['size'], 10)
Exemplo n.º 6
0
    def test_get_without_est(self):
        self.login_as_member('new')
        donor = Donor(membership_id=self.pre_id, firstname='Maebe')
        donor.save()

        res = self.client.get(self._get_url(donor.pk))

        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(res, 'fund/forms/edit_contact.html')
        self.assertIsInstance(res.context['form'], DonorPreForm)
Exemplo n.º 7
0
 def setUp(self):
   super(AddStep, self).setUp()
   self.login_as_member('new')
   donor = Donor(firstname='user', lastname='', membership_id=self.pre_id)
   donor.save()
   self.donor_id = donor.pk
   self.url = reverse('sjfnw.fund.views.add_step', kwargs={'donor_id': donor.pk})
   self.valid_form = {
     'date': '11/13/2034',
     'description': 'Talk to them'
   }
Exemplo n.º 8
0
    def test_multiple_received(self):
        donor = Donor(membership_id=self.pre_id,
                      firstname='Sally',
                      amount=40,
                      likelihood=75,
                      asked=True,
                      promised=40,
                      received_this=40)
        donor.save()
        donor = Donor(membership_id=self.pre_id,
                      firstname='Diego',
                      amount=200,
                      likelihood=50,
                      asked=True,
                      promised=300,
                      received_this=100,
                      received_next=100)
        donor.save()

        membership = Membership.objects.get(pk=self.pre_id)
        progress = membership.get_progress()
        self.assertEqual(progress['estimated'], 130)
        self.assertEqual(progress['promised'], 340)
        self.assertEqual(progress['received_this'], 140)
        self.assertEqual(progress['received_next'], 100)
        self.assertEqual(progress['received_afternext'], 0)
        self.assertEqual(progress['received_total'], 240)
Exemplo n.º 9
0
 def setUp(self):
   super(EditStep, self).setUp()
   self.login_as_member('new')
   donor = Donor(firstname='user', lastname='', membership_id=self.pre_id)
   donor.save()
   self.donor_id = donor.pk
   step = Step(donor_id=donor.pk, date='2034-11-13', description='Think about it')
   step.save()
   self.step_id = step.pk
   self.url = reverse('sjfnw.fund.views.edit_step',
                      kwargs={'donor_id': donor.pk, 'step_id': step.pk})
   self.valid_form = {
     'date': '11/13/2034',
     'description': 'Talk to them'
   }
Exemplo n.º 10
0
 def setUp(self):
     super(EditStep, self).setUp()
     self.login_as_member('new')
     donor = Donor(firstname='user', lastname='', membership_id=self.pre_id)
     donor.save()
     self.donor_id = donor.pk
     step = Step(donor_id=donor.pk,
                 date='2034-11-13',
                 description='Think about it')
     step.save()
     self.step_id = step.pk
     self.url = reverse('sjfnw.fund.views.edit_step',
                        kwargs={
                            'donor_id': donor.pk,
                            'step_id': step.pk
                        })
     self.valid_form = {'date': '11/13/2034', 'description': 'Talk to them'}
Exemplo n.º 11
0
    def test_get_promised(self):
        donor = Donor(firstname='A', membership_id=self.ship_id, promised=300)
        donor.save()
        donor = Donor(firstname='B', membership_id=self.ship_id)
        donor.save()

        res = self.client.get(self.url)

        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.context['size'], 1)
Exemplo n.º 12
0
    def test_multiple_received(self):
        donor = Donor(
            membership_id=self.pre_id,
            firstname="Sally",
            amount=40,
            likelihood=75,
            asked=True,
            promised=40,
            received_this=40,
        )
        donor.save()
        donor = Donor(
            membership_id=self.pre_id,
            firstname="Diego",
            amount=200,
            likelihood=50,
            asked=True,
            promised=300,
            received_this=100,
            received_next=100,
        )
        donor.save()

        membership = Membership.objects.get(pk=self.pre_id)
        progress = membership.get_progress()
        self.assertEqual(progress["estimated"], 130)
        self.assertEqual(progress["promised"], 340)
        self.assertEqual(progress["received_this"], 140)
        self.assertEqual(progress["received_next"], 100)
        self.assertEqual(progress["received_afternext"], 0)
        self.assertEqual(progress["received_total"], 240)
Exemplo n.º 13
0
    def test_combo(self):
        now = timezone.now()
        step = Step(donor_id=self.donor_id, date=now, description="Talk to this person")
        step.completed = now
        step.save()

        step = Step(donor_id=self.donor_id, date=now, description="Follow up")
        step.completed = now
        step.save()

        donor2 = Donor(membership_id=self.membership.pk, firstname="ADA")
        donor2.save()

        step = Step(donor_id=donor2.pk, date=now, description="Ask this other person")
        step.completed = now
        step.asked = True
        step.promised = 150
        step.save()

        donor3 = Donor(membership_id=self.membership.pk, firstname="Uncle so and so")
        donor3.save()

        step = Step(donor_id=donor3.pk, date=now, description="Ask for $$$")
        step.completed = now
        step.promised = 500
        step.save()

        self.membership.update_story(timezone.now())

        stories = self.membership.newsitem_set.all()
        self.assertEqual(len(stories), 1)
        story = stories[0]
        self.assertEqual(story.summary, u"Test talked to 2 people, asked 1 and got $650 in promises.")
Exemplo n.º 14
0
  def test_get_promised(self):
    donor = Donor(firstname='A', membership_id=self.ship_id, promised=300)
    donor.save()
    donor = Donor(firstname='B', membership_id=self.ship_id)
    donor.save()

    res = self.client.get(self.url)

    self.assertEqual(res.status_code, 200)
    self.assertEqual(res.context['size'], 1)
Exemplo n.º 15
0
    def test_combo(self):
        now = timezone.now()
        step = Step(donor_id=self.donor_id,
                    date=now,
                    description='Talk to this person')
        step.completed = now
        step.save()

        step = Step(donor_id=self.donor_id, date=now, description='Follow up')
        step.completed = now
        step.save()

        donor2 = Donor(membership_id=self.membership.pk, firstname='ADA')
        donor2.save()

        step = Step(donor_id=donor2.pk,
                    date=now,
                    description='Ask this other person')
        step.completed = now
        step.asked = True
        step.promised = 150
        step.save()

        donor3 = Donor(membership_id=self.membership.pk,
                       firstname='Uncle so and so')
        donor3.save()

        step = Step(donor_id=donor3.pk, date=now, description='Ask for $$$')
        step.completed = now
        step.promised = 500
        step.save()

        self.membership.update_story(timezone.now())

        stories = self.membership.newsitem_set.all()
        self.assertEqual(len(stories), 1)
        story = stories[0]
        self.assertEqual(
            story.summary,
            u'{} talked to 2 people, asked 1 and got $650 in promises.'.format(
                self.name))
Exemplo n.º 16
0
    def test_post_invalid(self):
        donor_a = Donor(membership_id=self.ship_id, firstname='Taboo')
        donor_a.save()
        donor_b = Donor(membership_id=self.ship_id, firstname='Boggle')
        donor_b.save()

        date = timezone.now() + timedelta(days=5)
        form_data = {
            'form-TOTAL_FORMS': u'2',
            'form-INITIAL_FORMS': u'2',
            'form-MAX_NUM_FORMS': u'10',
            'form-0-donor': unicode(donor_a.pk),
            'form-0-date': '{:%m/%d/%y}'.format(date),
            'form-1-donor': unicode(donor_b.pk),
            'form-1-description': 'Talk'
        }
        res = self.client.post(self.url, form_data)

        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(res, 'fund/forms/add_mult_step.html')
        self.assertFormsetError(res, 'formset', 0, 'description',
                                'This field is required.')
        self.assertFormsetError(res, 'formset', 1, 'date',
                                'Please enter a date in mm/dd/yyyy format.')
Exemplo n.º 17
0
  def test_post_invalid(self):
    donor_a = Donor(membership_id=self.ship_id, firstname='Taboo')
    donor_a.save()
    donor_b = Donor(membership_id=self.ship_id, firstname='Boggle')
    donor_b.save()

    date = timezone.now() + timedelta(days=5)
    form_data = {
      'form-TOTAL_FORMS': u'2',
      'form-INITIAL_FORMS': u'2',
      'form-MAX_NUM_FORMS': u'10',
      'form-0-donor': unicode(donor_a.pk),
      'form-0-date': '{:%m/%d/%y}'.format(date),
      'form-1-donor': unicode(donor_b.pk),
      'form-1-description': 'Talk'
    }
    res = self.client.post(self.url, form_data)

    self.assertEqual(res.status_code, 200)
    self.assertTemplateUsed(res, 'fund/forms/add_mult_step.html')
    self.assertFormsetError(res, 'formset', 0, 'description', 'This field is required.')
    self.assertFormsetError(res, 'formset', 1, 'date', 'Please enter a date in mm/dd/yyyy format.')
Exemplo n.º 18
0
 def test_no_promise(self):
   donor = Donor(membership_id=self.pre_id, firstname='Hello', amount=20, likelihood=75)
   donor.save()
   self.assertEqual(donor.total_promised(), 0)