Diff of /branches/1.1/turbogears/tests/test_controllers.py [r4328] .. [r4329] Maximize Restore

  Switch to side-by-side view

--- a/branches/1.1/turbogears/tests/test_controllers.py
+++ b/branches/1.1/turbogears/tests/test_controllers.py
@@ -74,8 +74,9 @@
         return str(value)
 
     @expose()
-    def callsanother(self):
-        return self.istrue(True)
+    @validate(validators={'value': validators.StringBoolean()})
+    def indirectistrue(self, value):
+        return self.istrue(str(value))
 
     @expose(format="json", html="turbogears.tests.simple")
     def returnjson(self):
@@ -371,6 +372,13 @@
         assert len(cherrypy.root.errors) == 1
         assert cherrypy.root.errors.has_key("firstname")
 
+    def test_validation_indirect(self):
+        """Data can be converted and validated if method call is nested"""
+        testutil.create_request("/indirectistrue?value=true")
+        assert cherrypy.root.value is True
+        testutil.create_request("/indirectistrue?value=false")
+        assert cherrypy.root.value is False
+
     def test_validation_with_schema(self):
         """Data can be converted/validated with formencode.Schema instance"""
         testutil.create_request("/save2?submit=send&firstname=Joe&lastname=Doe")
@@ -401,7 +409,7 @@
         """run_with_transaction is called only on topmost exposed method"""
         oldrwt = database.run_with_transaction
         database.run_with_transaction = cherrypy.root.rwt
-        testutil.create_request("/callsanother")
+        testutil.create_request("/indirectistrue?value=true")
         database.run_with_transaction = oldrwt
         assert cherrypy.root.value
         assert cherrypy.root.rwt_called == 1