functional testing: test against in-memory db, identity magic, longish test setup

0 views
Skip to first unread message

Max Ischenko

unread,
Jan 17, 2006, 8:09:57 AM1/17/06
to turbo...@googlegroups.com
Hello,

I'm writing some functional tests for my TG app and run into a problem.

In setup method, I do the following:
from turbogears import database
database.set_db_uri("sqlite:///:memory:")

This supposed to setup an in-memory test db and allow me to proceed with "import model" and go on with tests. The problem is that I got "tg_user table doesn't exist" error. I think that's because of auto-magic creation of identity tables that identity uses. The following fixes it but it feels very awkward:

from turbogears.identity.soprovider import SqlObjectIdentityProvider
SqlObjectIdentityProvider().create_provider_model()

(I'm using identity framework and my User class is derived from TG_User (I use TG_Group and TG_Permission as is, if that matters).

All in all, setup method is getting bigger and bigger. Currently I have:

import cherrypy
from turbogears.config import update_config
from turbogears import database
from turbogears.identity.soprovider import SqlObjectIdentityProvider

update_config('bookswap/config.py')
cherrypy.config.update(file='dev.cfg')
database.set_db_uri("sqlite:///:memory:")
SqlObjectIdentityProvider().create_provider_model()

That's just to setup a test env!

It'd be nice to be able to fold this longish setup somehow. Any suggestions?
I'm using nose so maybe moving this to setup_package is a good idea.

P.S.: What's the recommended way to configure logging during the tests?


Reply all
Reply to author
Forward
0 new messages