Testing TG2 apps

0 views
Skip to first unread message

Peter

unread,
Nov 23, 2009, 9:36:40 AM11/23/09
to turbo...@googlegroups.com
Hi
I was wondering if the document

http://docs.turbogears.org/1.0/Testing

still applies to TG2 or if the various changes to TG has induced changes
to the ( nosetests ) testing strategy

Thanks a lot for your comments
Peter

Diez B. Roggisch

unread,
Nov 23, 2009, 10:34:31 AM11/23/09
to turbo...@googlegroups.com
On Monday 23 November 2009 15:36:40 Peter wrote:
> Hi
> I was wondering if the document
>
> http://docs.turbogears.org/1.0/Testing
>
> still applies to TG2 or if the various changes to TG has induced changes
> to the ( nosetests ) testing strategy

No, it doesn't apply.

There seems no replacement for this page in the current docs (dunno about M.
Pedersens enhancements though).

However, it is based on webtest, which has a bit of docs itself, and you
should have some generated testcases that you can start working with.

Diez

Lukasz Szybalski

unread,
Nov 23, 2009, 1:13:09 PM11/23/09
to turbo...@googlegroups.com
I have one example here:
http://lucasmanual.com/mywiki/TurboGears2#TurboGears2.2BAC8-Addressbook.Testing.2BAC8-UnitTest

not sure how much more info do you need.
If you have some sample test cases code, please share...

Thanks,
Lucas

Peter

unread,
Nov 23, 2009, 5:41:02 PM11/23/09
to turbo...@googlegroups.com

> I have one example here:
> http://lucasmanual.com/mywiki/TurboGears2#TurboGears2.2BAC8-Addressbook.Testing.2BAC8-UnitTest
>
> not sure how much more info do you need.
> If you have some sample test cases code, please share...
>
>
Lukasz
Thanks for the link. In fact what I don't understand ( I am newbie to
Turbogears + SqlAlchemy ) the way model unit testing is set up ( I
don't understand neither your version nor the one generated by the
quickstart tutorials.

in tests/model/__init__.py :

# omitting includes

class ModelTest(object):
"""Base unit test case for the models."""

klass = None
attrs = {}

def setup(self):
try:
new_attrs = {}
new_attrs.update(self.attrs)
new_attrs.update(self.do_get_dependencies())
self.obj = self.klass(**new_attrs)
DBSession.add(self.obj)
DBSession.flush()
return self.obj
except:
DBSession.rollback()
raise


( As far as I understand your solution with the "recall" class is similar )
But how I am supposed to use that ? Lets suppose I want to test my model
class Page (from the wiki20 tut ):

class Page(DeclarativeBase):
__tablename__ = 'pages'

id=Column(Integer, primary_key=True)
pagename=Column(String(30), unique=True)
newcolumn=Column(String(20),unique=False)
data=Column(Text)

def __init__(self, pagename, data):
self.pagename = pagename
self.data = data


Peter

Reply all
Reply to author
Forward
0 new messages