From 47b0ffc9e284cfa91745718cee7ee920a766159f Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Fri, 20 Jun 2014 12:16:01 +0100 Subject: [PATCH] Add tests for notification preferences view --- .../tests/test_account_management.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/wagtail/wagtailadmin/tests/test_account_management.py b/wagtail/wagtailadmin/tests/test_account_management.py index 566d68723..56aa63560 100644 --- a/wagtail/wagtailadmin/tests/test_account_management.py +++ b/wagtail/wagtailadmin/tests/test_account_management.py @@ -177,6 +177,41 @@ class TestAccountSection(TestCase, WagtailTestUtils): # Check that the password was not changed self.assertTrue(User.objects.get(username='test').check_password('password')) + def test_notification_preferences_view(self): + """ + This tests that the notification preferences view responds with the + notification preferences page + """ + # Get notification preferences page + response = self.client.get(reverse('wagtailadmin_account_notification_preferences')) + + # Check that the user recieved a notification preferences page + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'wagtailadmin/account/notification_preferences.html') + + def test_notification_preferences_view_post(self): + """ + This posts to the notification preferences view and checks that the + user's profile is updated + """ + # Post new values to the notification preferences page + post_data = { + 'submitted_notifications': u'false', + 'approved_notifications': u'false', + 'rejected_notifications': u'true', + } + response = self.client.post(reverse('wagtailadmin_account_notification_preferences'), post_data) + + # Check that the user was redirected to the account page + self.assertRedirects(response, reverse('wagtailadmin_account')) + + profile = User.objects.get(username='test').get_profile() + + # Check that the notification preferences are as submitted + self.assertFalse(profile.submitted_notifications) + self.assertFalse(profile.approved_notifications) + self.assertTrue(profile.rejected_notifications) + class TestPasswordReset(TestCase, WagtailTestUtils): """