'With the setting enabled and receiving a private message should
send and email.'

@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()
    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))
