Skip to content

Commit

Permalink
Add tests for send_notification function
Browse files Browse the repository at this point in the history
These tests verify the functionality of the newly added
send_notification function when it is called with an active and inactive
user as the first argument.
  • Loading branch information
ericamador authored and bennylope committed Feb 17, 2017
1 parent 75069d9 commit 0a73762
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,38 @@ def test_activate_user(self):
self.pending_user.id,
self.tokenizer.make_token(self.pending_user)).status_code)

def test_send_notification_inactive_user(self):
"""
This test verifies that calling the send_notification function
from the OrganizationsCoreInvitationBackend with an inactive Django
user causes the function to return False without sending an email.
"""
org = Organization.objects.create(name="Test Organization")
result = InvitationBackend().send_notification(
self.pending_user,
domain='example.com',
organization=org,
sender=self.user)
self.assertEqual(result, False)
self.assertEquals(0, len(mail.outbox))

def test_send_notification_active_user(self):
"""
This test verifies that calling the send_notification function
from the OrganizationsCoreInvitationBackend with an active Django
user causes the function send an email to that user.
"""
org = Organization.objects.create(name="Test Organization")
InvitationBackend().send_notification(
self.user,
domain='example.com',
organization=org,
sender=self.pending_user)
self.assertEquals(1, len(mail.outbox))
self.assertEquals(
mail.outbox[0].subject,
u"You've been added to an organization")


@override_settings(USE_TZ=True)
class RegistrationTests(TestCase):
Expand Down

0 comments on commit 0a73762

Please sign in to comment.