示例#1
0
 def test_welcome_email(self):
     user = User.objects.filter().order_by('?')[0]
     with mock_signal_receiver(welcome_email) as receiver:
         welcome_email.send(sender=self, user=user)
         self.assertEqual(receiver.call_count, 1)
         send_mail = mail.outbox[0]
         self.assertEqual(len(mail.outbox), 1)
         expected_to = [user.email]
         self.assertEqual(expected_to, send_mail.to)
示例#2
0
 def post_save(self, obj, created=False):
     welcome_email.send(sender=self, user=obj)