def test_is_freelance_is_valid(self):
     with mock.patch("django.core.mail.EmailMultiAlternatives.send") as mock_send:
         self.assertTrue(self.tony_sarpino.freelanceprofile.is_freelance)
         report = ContributorReport(self.tony_sarpino)
         self.assertTrue(report.is_valid())
         report.send()
         self.assertTrue(mock_send.called)
 def test_is_freelance_is_valid(self):
     with mock.patch(
             "django.core.mail.EmailMultiAlternatives.send") as mock_send:
         self.assertTrue(self.tony_sarpino.freelanceprofile.is_freelance)
         report = ContributorReport(self.tony_sarpino)
         self.assertTrue(report.is_valid())
         report.send()
         self.assertTrue(mock_send.called)
 def test_no_contributions(self):
     with mock.patch("django.core.mail.EmailMultiAlternatives.send") as mock_send:
         Contribution.objects.all().delete()
         report = ContributorReport(self.tony_sarpino)
         self.assertEqual(report.total, 0)
         self.assertFalse(report.is_valid())
         report.send()
         self.assertFalse(mock_send.called)
 def test_no_contributions(self):
     with mock.patch(
             "django.core.mail.EmailMultiAlternatives.send") as mock_send:
         Contribution.objects.all().delete()
         report = ContributorReport(self.tony_sarpino)
         self.assertEqual(report.total, 0)
         self.assertFalse(report.is_valid())
         report.send()
         self.assertFalse(mock_send.called)
 def test_contribution_total_valid(self):
     LineItem.objects.create(contributor=self.tony_sarpino, amount=25)
     LineItem.objects.create(contributor=self.tony_sarpino, amount=25, payment_date=self.now)
     with mock.patch("django.core.mail.EmailMultiAlternatives.send") as mock_send:
         report = ContributorReport(self.tony_sarpino)
         self.assertEqual(report.total, 1525)
         self.assertTrue(report.is_valid())
         report.send()
         self.assertTrue(mock_send.called)
 def test_contribution_total_zero(self):
     with mock.patch("django.core.mail.EmailMultiAlternatives.send") as mock_send:
         for rate in self.draft_writer.flat_rates.all():
             rate.rate = 0
             rate.save()
         report = ContributorReport(self.tony_sarpino)
         self.assertEqual(report.total, 0)
         self.assertFalse(report.is_valid())
         report.send()
         self.assertFalse(mock_send.called)
 def test_contribution_total_zero(self):
     with mock.patch(
             "django.core.mail.EmailMultiAlternatives.send") as mock_send:
         for rate in self.draft_writer.flat_rates.all():
             rate.rate = 0
             rate.save()
         report = ContributorReport(self.tony_sarpino)
         self.assertEqual(report.total, 0)
         self.assertFalse(report.is_valid())
         report.send()
         self.assertFalse(mock_send.called)
 def test_contribution_total_valid(self):
     LineItem.objects.create(contributor=self.tony_sarpino, amount=25)
     LineItem.objects.create(contributor=self.tony_sarpino,
                             amount=25,
                             payment_date=self.now)
     with mock.patch(
             "django.core.mail.EmailMultiAlternatives.send") as mock_send:
         report = ContributorReport(self.tony_sarpino)
         self.assertEqual(report.total, 1525)
         self.assertTrue(report.is_valid())
         report.send()
         self.assertTrue(mock_send.called)
 def test_email_body(self):
     report = ContributorReport(self.tony_sarpino, month=self.next_month)
     self.assertTrue(report.get_body())
 def test_get_contributor_contributions_next_month(self):
     report = ContributorReport(self.tony_sarpino, month=self.next_month)
     self.assertEqual(report.contributions.count(), 25)
 def test_get_contributor_contributions_default(self):
     report = ContributorReport(self.tony_sarpino)
     self.assertEqual(report.contributions.count(), 25)
 def test_email_body(self):
     report = ContributorReport(self.tony_sarpino, month=self.next_month)
     self.assertTrue(report.get_body())