
from __future__ import ( absolute_import, division, print_function, unicode_literals) import six import logging from django.core.urlresolvers import reverse from django.test import Client, SimpleTestCase from django.test.utils import override_settings from urllib2 import HTTPError from django.contrib.auth.models import User from postorius.utils import get_client from postorius.tests import MM_VCR logger = logging.getLogger(__name__) vcr_log = logging.getLogger('vcr') vcr_log.setLevel(logging.WARNING) API_CREDENTIALS = {'MAILMAN_API_URL': 'http://localhost:9001', 'MAILMAN_USER': 'restadmin', 'MAILMAN_PASS': 'restpass'} @override_settings(**API_CREDENTIALS) class ListDeletePageTest(SimpleTestCase): """Tests for the list index page.""" @MM_VCR.use_cassette('test_list_index.yaml') def setUp(self): self.mm_client = get_client() self.client = Client() try: self.domain = self.mm_client.create_domain('example.com') except HTTPError: self.domain = self.mm_client.get_domain('example.com') self.foo_list = self.mm_client.get_list('foo@example.com') self.superuser=User.objects.create_superuser('sup','sup@example.com','pswd') @MM_VCR.use_cassette('test_list_index.yaml') def test_list_delete_contains_no_list(self): self.client.login(username='sup',password='pswd') response1 = self.client.get(reverse('list_delete',args=['foo@example.com']),follow=True) self.assertEqual(response1.status_code,200) self.client.post(reverse('list_delete',args=['foo@example.com']),follow=True) self.assertRedirects(response1,reverse('list_index'),status_code=302) response2=self.client.get(reverse('list_delete')) self.asserEqual(len(response2.context['lists']), 0) @MM_VCR.use_cassette('test_list_index.yaml') def tearDown(self): self.superuser.delete() self.client.delete_domain('example.org') -- You received this bug notification because you are a member of Mailman Coders, which is subscribed to GNU Mailman. https://bugs.launchpad.net/bugs/1414352 Title: Improve code coverage by adding tests To manage notifications about this bug go to: https://bugs.launchpad.net/mailman/+bug/1414352/+subscriptions