Commits

Robert Brewer committed 9ae7378

New POST request tests.

Comments (0)

Files changed (1)

cherrypy/test/test_tutorials.py

     def test03GetAndPost(self):
         load_tut_module("tut03_get_and_post")
         
+        # Try different GET queries
         helper.request("/greetUser?name=Bob")
         self.assertEqual(cpg.response.body, "Hey Bob, what's up?")
         
         helper.request("/greetUser?name=")
         self.assertEqual(cpg.response.body,
                          'No, really, enter your name <a href="./">here</a>.')
+        
+        # Try the same with POST
+        h = [("Content-type", "application/x-www-form-urlencoded"),
+             ("Content-Length", "8")]
+        helper.request("/greetUser", h, "POST", "name=Bob")
+        self.assertEqual(cpg.response.body, "Hey Bob, what's up?")
+        
+        h = [("Content-type", "application/x-www-form-urlencoded"),
+             ("Content-Length", "5")]
+        helper.request("/greetUser", h, "POST", "name=")
+        self.assertEqual(cpg.response.body,
+                         'No, really, enter your name <a href="./">here</a>.')
     
     def test04ComplexSite(self):
         load_tut_module("tut04_complex_site")