Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
widget test
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Disrupt07  
View profile  
 More options Apr 9 2007, 4:08 am
From: "Disrupt07" <cvbn...@gmail.com>
Date: Mon, 09 Apr 2007 01:08:29 -0700
Local: Mon, Apr 9 2007 4:08 am
Subject: widget test
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?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Wilson  
View profile  
(1 user)  More options Apr 9 2007, 4:27 am
From: "Ian Wilson" <vengfulsquir...@gmail.com>
Date: Mon, 9 Apr 2007 01:27:01 -0700
Local: Mon, Apr 9 2007 4:27 am
Subject: Re: [TurboGears] widget test
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Disrupt07  
View profile  
 More options Apr 9 2007, 4:54 am
From: "Disrupt07" <cvbn...@gmail.com>
Date: Mon, 09 Apr 2007 01:54:50 -0700
Local: Mon, Apr 9 2007 4:54 am
Subject: Re: widget test
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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Wilson  
View profile  
(1 user)  More options Apr 9 2007, 5:10 am
From: "Ian Wilson" <vengfulsquir...@gmail.com>
Date: Mon, 9 Apr 2007 02:10:58 -0700
Local: Mon, Apr 9 2007 5:10 am
Subject: Re: [TurboGears] Re: widget test
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Disrupt07  
View profile  
 More options Apr 9 2007, 6:43 am
From: "Disrupt07" <cvbn...@gmail.com>
Date: Mon, 09 Apr 2007 03:43:03 -0700
Local: Mon, Apr 9 2007 6:43 am
Subject: Re: widget test
Thanks a lot.

Some of my (related) questions are:

Can one test method have multiple assert statements?

What other assert statements can be created? (e.g. not just string
match)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alberto Valverde  
View profile  
 More options Apr 9 2007, 6:53 am
From: Alberto Valverde <albe...@toscat.net>
Date: Mon, 9 Apr 2007 12:53:45 +0200
Local: Mon, Apr 9 2007 6:53 am
Subject: Re: [TurboGears] Re: widget test

On Apr 9, 2007, at 12:43 PM, Disrupt07 wrote:

> Thanks a lot.

> Some of my (related) questions are:

> Can one test method have multiple assert statements?

Yes, as many as you'd like. However, it's good practice to group  
related asserts under the same function with a self describing name.  
Keep in mind that when one assert fails, the ones that follow it  
under the same function wont be executed.

> What other assert statements can be created? (e.g. not just string
> match)

You can assert any boolean condition:

assert 1 + 1 == 2
assert is_active()
assert True
etc...

Alberto


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Godoy  
View profile  
 More options Apr 9 2007, 6:56 am
From: Jorge Godoy <jgo...@gmail.com>
Date: Mon, 09 Apr 2007 07:56:10 -0300
Local: Mon, Apr 9 2007 6:56 am
Subject: Re: [TurboGears] Re: widget test

"Disrupt07" <cvbn...@gmail.com> writes:
> Thanks a lot.

> Some of my (related) questions are:

> Can one test method have multiple assert statements?

Yes, but then it's not a "unit" anymore.  Why not having multiple tests
testing each behavior?

> What other assert statements can be created? (e.g. not just string
> match)

Take a look at the docs for the test module you're using.  There are several
of them...

For the standard case: http://docs.python.org/lib/module-unittest.html

--
Jorge Godoy      <jgo...@gmail.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Wilson  
View profile  
(1 user)  More options Apr 9 2007, 7:05 am
From: "Ian Wilson" <vengfulsquir...@gmail.com>
Date: Mon, 9 Apr 2007 04:05:04 -0700
Local: Mon, Apr 9 2007 7:05 am
Subject: Re: [TurboGears] Re: widget test
Ha you guys are fast.

In addition to what they said you probably want to focus on 4
potential problems(4 tests).

1.  Make sure the widget's template compiles and you can import it..
by trying to import it.
from project.widgets import MyWidget

2. Make sure the widget instantiates.
myWidget = MyWidget(**defaultParams)

3.  Make sure the wiget's template is correctly interpolating by calling render.
myWidgetOutput = myWidget.render(**params)

4.  Check that the output of the widget's render method is correct by
checking string inclusion.
assert someString in myWidgetOutput

-Ian

On 4/9/07, Jorge Godoy <jgo...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Godoy  
View profile  
 More options Apr 9 2007, 7:51 am
From: Jorge Godoy <jgo...@gmail.com>
Date: Mon, 09 Apr 2007 08:51:08 -0300
Local: Mon, Apr 9 2007 7:51 am
Subject: Re: [TurboGears] Re: widget test

I like testing with the toolbox as well.  This makes me write a description to
it, document every variable I use and I have a test case that can be used by
other people without they having to look at my source code.

--
Jorge Godoy      <jgo...@gmail.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Disrupt07  
View profile  
 More options Apr 9 2007, 9:28 am
From: "Disrupt07" <cvbn...@gmail.com>
Date: Mon, 09 Apr 2007 06:28:38 -0700
Local: Mon, Apr 9 2007 9:28 am
Subject: Re: widget test
@all
Thanks, your info was very helpful.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google