summaryrefslogtreecommitdiff
path: root/tests/modeltests/test_client/models.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-03-22 10:23:52 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-03-22 10:23:52 +0000
commitf157bcefcac9b921658c6782d4a64c173a203f12 (patch)
tree73f7824d638592fd98b7ca51f61fd14c27cb0b85 /tests/modeltests/test_client/models.py
parent635fedcfa8570006830595a4083ca0c8981bed55 (diff)
Fixes #3212 -- Added code to test client to allow posting of multi-form values (e.g., MultipleChoiceFields). Thanks, Ben Dean Kawamura.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/test_client/models.py')
-rw-r--r--tests/modeltests/test_client/models.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py
index a3a9749162..75f3c49908 100644
--- a/tests/modeltests/test_client/models.py
+++ b/tests/modeltests/test_client/models.py
@@ -81,7 +81,43 @@ class ClientTest(TestCase):
# Check that the response was a 302 (redirect)
self.assertEqual(response.status_code, 302)
-
+
+ def test_valid_form(self):
+ "POST valid data to a form"
+ post_data = {
+ 'text': 'Hello World',
+ 'email': 'foo@example.com',
+ 'value': 37,
+ 'single': 'b',
+ 'multi': ('b','c','e')
+ }
+ response = self.client.post('/test_client/form_view/', post_data)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.template.name, "Valid POST Template")
+
+ def test_incomplete_data_form(self):
+ "POST incomplete data to a form"
+ post_data = {
+ 'text': 'Hello World',
+ 'value': 37
+ }
+ response = self.client.post('/test_client/form_view/', post_data)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.template.name, "Invalid POST Template")
+
+ def test_form_error(self):
+ "POST erroneous data to a form"
+ post_data = {
+ 'text': 'Hello World',
+ 'email': 'not an email address',
+ 'value': 37,
+ 'single': 'b',
+ 'multi': ('b','c','e')
+ }
+ response = self.client.post('/test_client/form_view/', post_data)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.template.name, "Invalid POST Template")
+
def test_unknown_page(self):
"GET an invalid URL"
response = self.client.get('/test_client/unknown_view/')