diff mbox

[09/11] tests/test_user: Add "profile POST" tests

Message ID 1435654329-19960-10-git-send-email-stephen.finucane@intel.com
State Superseded
Headers show

Commit Message

Stephen Finucane June 30, 2015, 8:52 a.m. UTC
POSTing to the 'profile' view will allow configuration of some user
profiles, but this was not being tested. Resolve this.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
---
 patchwork/tests/test_user.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Comments

Damien Lespiau Aug. 19, 2015, 1:53 p.m. UTC | #1
On Tue, Jun 30, 2015 at 09:52:07AM +0100, Stephen Finucane wrote:
> POSTing to the 'profile' view will allow configuration of some user
> profiles, but this was not being tested. Resolve this.
> 
> Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>

Looks fine to me:

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
diff mbox

Patch

diff --git a/patchwork/tests/test_user.py b/patchwork/tests/test_user.py
index 46e6d09..6814ecc 100644
--- a/patchwork/tests/test_user.py
+++ b/patchwork/tests/test_user.py
@@ -22,7 +22,7 @@  from django.core import mail
 from django.core.urlresolvers import reverse
 from django.conf import settings
 from django.contrib.auth.models import User
-from patchwork.models import EmailConfirmation, Person, Bundle
+from patchwork.models import EmailConfirmation, Person, Bundle, UserProfile
 from patchwork.tests.utils import defaults, error_strings
 
 
@@ -156,6 +156,27 @@  class UserProfileTest(TestCase):
         self.assertContains(response, 'You have the following bundle')
         self.assertContains(response, bundle.get_absolute_url())
 
+    def testUserProfileValidPost(self):
+        user_profile = UserProfile.objects.get(user=self.user.user.id)
+        old_ppp = user_profile.patches_per_page
+        new_ppp = old_ppp + 1
+
+        response = self.client.post('/user/', {'patches_per_page': new_ppp})
+
+        user_profile = UserProfile.objects.get(user=self.user.user.id)
+        self.assertEquals(user_profile.patches_per_page, new_ppp)
+
+    def testUserProfileInvalidPost(self):
+        user_profile = UserProfile.objects.get(user=self.user.user.id)
+        old_ppp = user_profile.patches_per_page
+        new_ppp = -1
+
+        response = self.client.post('/user/', {'patches_per_page': new_ppp})
+
+        user_profile = UserProfile.objects.get(user=self.user.user.id)
+        self.assertEquals(user_profile.patches_per_page, old_ppp)
+
+
 class UserPasswordChangeTest(TestCase):
     user = None