Skip to content
Browse files

Tests for args to BoundAction.render().

  • Loading branch information...
1 parent ffc07a6 commit 66cb1677b655cce908743e88194d8a958ca3ebc2 @zacharyvoase committed Sep 13, 2012
Showing with 13 additions and 6 deletions.
  1. +2 −6 example/users/resources.py
  2. +11 −0 example/users/tests/test_integration.py
View
8 example/users/resources.py
@@ -37,9 +37,7 @@ def create(self):
self.user = self.form.save()
return redirect('User#show', str(self.user.id))
- response = self.new.render()
- response.status_code = 403
- return response
+ return self.new.render(status=403)
@action
def show(self, user_id):
@@ -62,9 +60,7 @@ def update(self, user_id):
self.form.save()
return redirect('User#show', str(self.user.id))
- response = self.edit.render()
- response.status_code = 403
- return response
+ return self.edit.render(status=403)
@action
def destroy(self, user_id):
View
11 example/users/tests/test_integration.py
@@ -54,6 +54,17 @@ def test_create(self):
eventual_user_count = models.User.objects.count()
self.assertEqual(eventual_user_count, initial_user_count + 1)
+ def test_create_invalid(self):
+ initial_user_count = models.User.objects.count()
+ response = self.client.post("/users/", {
+ "username": "!!",
+ "password1": "foo",
+ "password2": "bar"
+ })
+ self.assertEqual(response.status_code, 403)
+ eventual_user_count = models.User.objects.count()
+ self.assertEqual(eventual_user_count, initial_user_count)
+
def test_show(self):
self.create_user()

0 comments on commit 66cb167

Please sign in to comment.
Something went wrong with that request. Please try again.