Skip to content

Commit

Permalink
[#2312] Fix test for sending donation confirmation emails
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Aug 12, 2016
1 parent f8b6955 commit 5095048
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ omit =
[report]
exclude_lines =
pragma: no cover
if settings.DEBUG:
def __unicode__
if 'TRAVIS' in os.environ:
if 'rosetta' in settings.INSTALLED_APPS:
Expand Down
16 changes: 15 additions & 1 deletion akvo/rsr/tests/rsr_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
"""

from akvo.rsr.models import User, Project, Invoice, Country, Keyword, Sector
from akvo.rsr.models import (User, Project, Invoice, Country, Keyword, Sector, PayPalGateway,
PaymentGatewaySelector)
from akvo.codelists.models import Sector as CodelistSector
from akvo.utils import (rsr_send_mail_to_users, model_and_instance_based_filename,
send_donation_confirmation_emails, who_am_i, who_is_parent, to_gmt,
Expand Down Expand Up @@ -62,13 +63,26 @@ def test_send_donation_confirmation_emails(self):
"""
Test sending a confirmation email for donations.
"""
# Add a new invoice
invoice = Invoice.objects.create(
test=True,
user=self.user,
project=self.project,
amount=50,
)

# Make sure the project has a PayPal gateway
paypal_gateway, _created = PayPalGateway.objects.get_or_create(
name='PayPal',
notification_email='paypal.test@akvo.org',
account_email='paypal.test@akvo.org',
)
send_donation_confirmation_emails(invoice)
payment_gateway_selector, _created = PaymentGatewaySelector.objects.get_or_create(
project=self.project
)
payment_gateway_selector.paypal_gateway = paypal_gateway
payment_gateway_selector.save()

# Test that the mail is in the outbox.
self.assertIn("Thank you from Akvo.org!", [sent_mail.subject for sent_mail in mail.outbox])
Expand Down

0 comments on commit 5095048

Please sign in to comment.