def test_send_mail_errors(self):
    'Check error cases.'
    url = '{}?action=compose'.format(reverse('modoboa_webmail:index'))
    response = self.client.get(url)
    self.assertEqual(response.status_code, 200)
    response = self.ajax_post(url, {'to': '', 'subject': 'test', 'body': 'Test'}, 400)
    self.assertEqual(len(mail.outbox), 0)
Check error cases.
def test_send_mail_errors(self):
    
    url = '{}?action=compose'.format(reverse('modoboa_webmail:index'))
    response = self.client.get(url)
    self.assertEqual(response.status_code, 200)
    response = self.ajax_post(url, {'to': , 'subject': 'test', 'body': 'Test'}, 400)
    self.assertEqual(len(mail.outbox), 0)