Hello,
Based on the docstring I think you can assume for the most part that
it acts just like the display method. You only need to pass the
params you would have needed at display time. Ie. whatever you define
in params in your Widget's definition. And you should expect back the
populated html.
Here is the docstring looked up on one of my instantiated widgets in
tg-admin shell:
render(self, value=None, format='html', **params)
Exactly the same as display() but return serialized output instead.
Useful for debugging or to display the widget in a non-Kid template like
Cheetah, STAN, ...
Another note if you need to make sure that the css/js are working you
can do something like this:
mw = MyWidget()
for cssWidget in mw.retrieve_css():
cssString = cssString + cssWidget.render()
assert 'some css string' in cssString
assert 'some css link' in cssString
for jsWidget in mw.retrieve_javascript():
jsString = jsString + jsWidget.render()
assert 'some js string' in jsString
assert 'some js link' in jsString
retrieve_css and retrieve_javascript are used by the master.kid (KID)
or master.html(GENSHI) to get the css and js that should be included
when a widget is returned from a controller.
Testing this out in tg-admin shell first will help you see what I mean
and you can work out the details you will need when setting up your
tests.
Tell me if this all doesn't make sense.
-Ian
On 4/9/07, Disrupt07 <cvbn...@gmail.com> wrote:
> Thanks.
> Yes, unit testing in the way you defined is fine. I started looking
> into the .render method. What parameters should I pass and what
> output should I expect from .render method? How should the assert
> part be?
> Ian Wilson wrote:
> > Can you be more specific? Like testing what they output? You can
> > probably just make the widgets and call render() and test against
> > that.
> > def test_MyWidget()
> > paramsForMyWidget = dict(...)
> > mw = MyWidget()
> > widgetOutput = mw.render(**paramsForMyWidget)
> > assert 'some string' in widgetOutput
> > -Ian
> > On 4/9/07, Disrupt07 <cvbn...@gmail.com> wrote:
> > > I am trying to unit-test widgets using nosetests. I need examples of
> > > this. Is there any documentation I can follow for unit testing
> > > widgets?