def test_textfield(): """Test form rendering inside a request.""" #form name is prepended to element ids only when running inside a request. class MyField(widgets.WidgetsList): blonk = widgets.TextField() tf = widgets.ListForm(fields=MyField()) class MyFieldOverrideName(widgets.WidgetsList): blonk = widgets.TextField(name="blink") tf2 = widgets.ListForm(fields=MyFieldOverrideName()) class MyRoot(controllers.RootController): @expose() def fields(self): return tf.render(format='xhtml') @expose() def override(self): return tf2.render(format='xhtml') testutil.mount(MyRoot(), '/') app = testutil.make_app() r = app.get('/fields') assert 'name="blonk"' in r assert 'id="form_blonk"' in r r = app.get('/override') assert 'name="blink"' in r assert 'id="form_blink"' in r
def test_can_use_internally_defined_arguments(self): """Can use argument names that are internally used by TG in controllers""" class App(controllers.RootController): @expose() def index(self, **kw): return "\n".join(["%s:%s" % i for i in kw.iteritems()]) testutil.mount(App(), '/') response = self.app.get("/?format=foo&template=bar&fragment=boo") assert "format:foo" in response assert "template:bar" in response assert "fragment:boo" in response
def setup_module(): testutil.unmount() testutil.mount(MyRoot()) testutil.start_server()
def test_index_trailing_slash(self): """If there is no trailing slash on an index method call, redirect""" testutil.mount(SubApp(), '/') testutil.mount(SubApp(), '/foo') self.app.get("/foo", status=302)
def setUp(self): testutil.mount(MyRoot(), '/') testutil.mount(SubApp(), '/subthing') testutil.mount(SubApp(), '/subthing/subsubthing') self.app = testutil.make_app() super(TestURLs, self).setUp()
def setUp(self): browse_data(browse) testutil.mount(MyRoot(), "/") testutil.mount(CatWalk(browse), '/catwalk') self.app = testutil.make_app()
def setup_module(): testutil.unmount() testutil.mount(MyRoot()) testutil.mount(NestedController(), "/nestedcontroller") testutil.start_server()