def test_invite_content(self): """Verify the email content is correct.""" invite = mommy.make('accounts.Invite') self.assertFalse(invite.notified) with patch('open_connect.accounts.tasks.send_email') as mock: render_and_send_invite_email(invite.pk) call_args = mock.call_args[1] self.assertEqual(call_args['email'], invite.email) self.assertEqual(call_args['from_email'], settings.DEFAULT_FROM_EMAIL) # Confirm that the unsubscribe URL is in the message self.assertIn(unsubscribe_url(invite.email), call_args['text']) self.assertIn(unsubscribe_url(invite.email), call_args['html']) invite = Invite.objects.get(pk=invite.pk) self.assertIsInstance(invite.notified, datetime)
def test_invite_content(self): """Verify the email content is correct.""" invite = mommy.make("accounts.Invite") self.assertFalse(invite.notified) with patch("open_connect.accounts.tasks.send_email") as mock: render_and_send_invite_email(invite.pk) call_args = mock.call_args[1] self.assertEqual(call_args["email"], invite.email) self.assertEqual(call_args["from_email"], settings.DEFAULT_FROM_EMAIL) # Confirm that the unsubscribe URL is in the message self.assertIn(unsubscribe_url(invite.email), call_args["text"]) self.assertIn(unsubscribe_url(invite.email), call_args["html"]) invite = Invite.objects.get(pk=invite.pk) self.assertIsInstance(invite.notified, datetime)
def test_unsubscribe_url(self): """Test that all the required components are in the URL""" result = utils.unsubscribe_url('*****@*****.**') unsub_url = reverse('unsubscribe') code = generate_nologin_hash('*****@*****.**') self.assertIn(unsub_url, result) self.assertIn('code=%s' % code, result) self.assertIn('[email protected]', result) self.assertIn('http://connect.local', result)
def unsubscribe_url(self): """URL the user visits to unsubscribe from all emails""" return unsubscribe_url(self.email)
def unsubscribe_link(email): """Tag which returns the URL to unsubscribe for an email""" return unsubscribe_url(email)