def emailinvitation(self): invitation = Invitation.objects.first() if invitation is None: invited_by = random_user() group = Group.objects.first() invitation = Invitation.objects.create(group=group, invited_by=invited_by, email='*****@*****.**') return email_utils.prepare_emailinvitation_email(invitation)
def test_emailinvitation(self): invitation = Invitation.objects.create( email='*****@*****.**', group=self.group, invited_by=self.user ) email = email_utils.prepare_emailinvitation_email(invitation) self.assertEqual(len(email.alternatives), 0) self.assertEqual(email.to[0], '*****@*****.**') self.assertIn(self.group.name, email.body) self.assertIn(self.user.display_name, email.body) self.assertIn(str(invitation.token), email.body) self.assertIn(settings.SITE_NAME, email.body) self.assertIn(settings.HOSTNAME, email.body) self.assertNotIn('&', email.body)
def send_mail(self): email_utils.prepare_emailinvitation_email(self).send()