@mock.patch.object(Site.objects, 'get_current')
    def test_private_message_sends_email(self, get_current):
        get_current.return_value.domain = 'testserver'

        s, c = Setting.objects.get_or_create(user=self.to, name='email_private_messages')
        s.value = True
        s.save()
        # User has setting, and should recieve notification email.

        assert Setting.get_for_user(self.to, 'email_private_messages')

        self.client.login(username=self.sender.username, password='testpass')
        post(self.client, 'messages.new',
             {'to': self.to, 'message': 'a message'})
        subject = u'[SUMO] You have a new private message from [{sender}]'

        attrs_eq(mail.outbox[0], to=[self.to.email],
                 subject=subject.format(sender=self.sender.profile.name))
        starts_with(mail.outbox[0].body,
                    PRIVATE_MESSAGE_EMAIL.format(sender=self.sender.profile.name))
With the setting enabled and receiving a private message should
dataset/ETHPy150Open mozilla/kitsune/kitsune/messages/tests/test_notifications.py/NotificationsTests.test_private_message_sends_email