def test_delattachment_errors(self):
    'Check error cases.'
    url = reverse('modoboa_webmail:index')
    response = self.client.get('{}?action=compose'.format(url))
    self.assertEqual(response.status_code, 200)
    self.assertIn('compose_mail', self.client.session)
    url = reverse('modoboa_webmail:attachment_delete')
    with self.settings(MEDIA_ROOT=self.workdir):
        response = self.ajax_get('{}?name='.format(url))
    self.assertEqual(response['status'], 'ko')
    self.assertEqual(response['respmsg'], 'Bad query')
    with self.settings(MEDIA_ROOT=self.workdir):
        response = self.ajax_get('{}?name=test'.format(url))
    self.assertEqual(response['status'], 'ko')
    self.assertEqual(response['respmsg'], 'Unknown attachment')
Check error cases.
def test_delattachment_errors(self):
    
    url = reverse('modoboa_webmail:index')
    response = self.client.get('{}?action=compose'.format(url))
    self.assertEqual(response.status_code, 200)
    self.assertIn('compose_mail', self.client.session)
    url = reverse('modoboa_webmail:attachment_delete')
    with self.settings(MEDIA_ROOT=self.workdir):
        response = self.ajax_get('{}?name='.format(url))
    self.assertEqual(response['status'], 'ko')
    self.assertEqual(response['respmsg'], 'Bad query')
    with self.settings(MEDIA_ROOT=self.workdir):
        response = self.ajax_get('{}?name=test'.format(url))
    self.assertEqual(response['status'], 'ko')
    self.assertEqual(response['respmsg'], 'Unknown attachment')