Hi,
I am attempting to port TGWebServices to TG 2.0. So far so good, I can do
basic requests in json or xml.
Before going further I need to have unittests... and here starts the hard
part (for me) :
For now I have a tgext.ws.tests module, in which I would like everything
needed to run a minimalistic tg2 app (no database, no templates, no
renderers, no static files). Its __init__.py is attached.
The app_factory function seems to work, and I obtain, on my TestController,
a self.app attribute.
Since I have no controller and when I perform a self.app.get() routes
complains : "No such file or directory:
'/home/cdevienne/ws/tgws-2.0/tgext/ws/tests/controllers'".
The question is :
- how do I set a specific root controller, and is it related to
"setup_paths" on AppConfig ?
I don't want the root to be found automatically because each test class will
use its own. Moreover the tgext/ws/tests/controllers does not exist, and I
would prefer not to have too much files in tests.
If I am unclear, please tell me.
Thanks for any hint,
Christophe
--
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en.
from tg import config
from paste.deploy import loadapp
from paste.script.appinstall import SetupCommand
from tg.configuration import AppConfig
from webtest import TestApp
class lib(object):
class app_globals(object):
class Globals(object):
pass
class helpers(object):
pass
def app_factory(global_conf, full_stack=True, **app_conf):
import tgext.ws.tests
app_config = AppConfig()
app_config.renderers = []
app_config.package = tgext.ws.tests
app_config.default_renderer = 'genshi'
app_config.renderers.append('genshi')
app_config.use_sqlalchemy = False
load_environment = app_config.make_load_environment()
make_base_app = app_config.setup_tg_wsgi_app(load_environment)
app = make_base_app(global_conf, full_stack=True, **app_conf)
return app
class TestController(object):
def setUp(self):
#conf_dir = config.here
wsgiapp = loadapp('config:test.ini#main', relative_to='.')
self.app = TestApp(wsgiapp)
# TODO set the application root to self.root