diff --git a/src/postorius/tests/mailman_api_tests/test_domain_new.py b/src/postorius/tests/mailman_api_tests/test_domain_new.py index 7ae861e..23ae745 100644 --- a/src/postorius/tests/mailman_api_tests/test_domain_new.py +++ b/src/postorius/tests/mailman_api_tests/test_domain_new.py @@ -41,10 +41,9 @@ post_data = {'mail_host': 'example.com', 'web_host': 'http://example.com', 'description': 'A new Domain.'} - response = self.client.post(reverse('domain_new'), post_data, - follow=True) + response = self.client.post(reverse('domain_new'), post_data) - self.assertContains(response, 'New Domain registered') + self.assertHasSuccessMessage(response) self.assertRedirects(response, reverse('domain_index')) a_new_domain = self.mm_client.get_domain('example.com') @@ -53,3 +52,12 @@ self.assertEqual(a_new_domain.owners[0]['user_id'], self.mm_client.get_user('su@example.com').user_id) a_new_domain.delete() + + def test_validation_of_mail_host(self): + self.client.login(username='su', password='pwd') + post_data = {'mail_host': 'example com', + 'web_host': 'http://example.com', + 'description': 'A new Domain'} + response = self.client.post(reverse('domain_new'), post_data) + self.assertHasErrorMessage(response) + self.assertEquals(response.status_code, 200) diff --git a/src/postorius/tests/mailman_api_tests/test_list_new.py b/src/postorius/tests/mailman_api_tests/test_list_new.py index cb3bae5..d4f8733 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_new.py +++ b/src/postorius/tests/mailman_api_tests/test_list_new.py @@ -44,7 +44,21 @@ 'list_owner': 'owner@example.com', 'advertised': 'True', 'description': 'A new list.'} - self.client.post(reverse('list_new'), post_data) + response = self.client.post(reverse('list_new'), post_data) + self.assertHasSuccessMessage(response) a_new_list = self.mm_client.get_list('a_new_list@example.com') self.assertEqual(a_new_list.fqdn_listname, u'a_new_list@example.com') self.assertEqual(a_new_list.owners, [u'owner@example.com']) + + def test_listname_validation(self): + self.client.login(username='su', password='pwd') + post_data = {'listname': 'a new list', + 'mail_host': 'example.com', + 'list_owner': 'owner@example.com', + 'advertised': 'True', + 'description': 'A new list.'} + response = self.client.post(reverse('list_new'), post_data) + self.assertEquals(response.status_code, 200) + self.assertHasErrorMessage(response) + self.assertContains(response, 'Please enter a valid listname') + diff --git a/src/postorius/tests/mailman_api_tests/test_user.py b/src/postorius/tests/mailman_api_tests/test_user.py index e28b3f7..e2fb190 100644 --- a/src/postorius/tests/mailman_api_tests/test_user.py +++ b/src/postorius/tests/mailman_api_tests/test_user.py @@ -24,6 +24,7 @@ from postorius.models import MailmanUser, Mailman404Error from postorius.tests.utils import ViewTestCase +from postorius.forms import UserPreferences, ChangeSubscriptionForm class MailmanUserTest(ViewTestCase): @@ -118,3 +119,32 @@ self.assertEqual(response.status_code, 200) # The Mailman user must have been created self.assertIsNotNone(MailmanUser.objects.get(address=user.email)) + + def test_presence_of_form_in_user_global_settings(self): + self.client.login(username='user', password='testpass') + response = self.client.get(reverse('user_mailmansettings')) + self.assertEquals(response.status_code, 200) + self.assertIsInstance(response.context['settingsform'], + UserPreferences) + + def test_presence_of_form_in_user_subscription_preferences(self): + self.client.login(username='user', password='testpass') + self.foo_list.subscribe(self.user.email, pre_verified=True, + pre_confirmed=True, pre_approved=True) + response = self.client.get(reverse('user_subscription_preferences')) + self.assertEquals(response.status_code, 200) + self.assertIsNotNone(response.context['zipped_data']) + self.assertEquals(len(response.context['zipped_data']), 1) + + def test_presence_of_form_in_user_list_options(self): + self.client.login(username='user', password='testpass') + self.foo_list.subscribe(self.user.email, pre_verified=True, + pre_confirmed=True, pre_approved=True) + response = self.client.get(reverse('user_list_options', + args=[self.foo_list.list_id])) + self.assertEquals(response.status_code, 200) + self.assertIsInstance(response.context['form'], + UserPreferences) + self.assertIsInstance(response.context['change_subscription_form'], + ChangeSubscriptionForm) +