On Jun 11, 10:11 am, "Agustin Villena" <[EMAIL PROTECTED]>
wrote:
> If I understand, this class may replace de standard TestController from
> pylons?
I ended up changing Alberto's code so it subclasses TestController.
class WSGIAppSecurityTestCase(TestController):
def __init__(self, *args, **kw):
TestController.__init__(self, *args, **kw)
try:
app = self.app
except AttributeError:
name = '.'.join([self.__class__.__module__,
self.__class__.__name__])
raise AttributeError(
"You need to place the wsgi app to test at "
"%s's 'app' attribute" % name)
if not isinstance(app, paste.fixture.TestApp):
self.app = paste.fixture.TestApp(app)
else:
self.app = app
...
My Pylons app is called MessagesTest, so I added the
WSGIAppSecurityTestCase class to the bottom of
MessagesTest.messagestest.tests.__init__.py and changed the __all__
attribute to read
__all__ = ['url_for', 'TestController', 'WSGIAppSecurityTestCase']
My test controller (in
MessagesTest.messagestest.tests.functional.test_messages.py) now
subclasses WSGIAppSecurityTestCase instead of TestController.
class TestMessagesController(WSGIAppSecurityTestCase):
def test_create(self):
response = self.post(url_for('messages'), 'dn')
response.mustcontain('create')
Two things to note in the test_create() method above:
* I had been using self.app.post() but had to change it to self.post()
(and similar for get(), etc.).
* I'm passing in the name of the remote user as the second argument to
self.post() (and for the other WSGIAppSecurityTestCase methods).
Hope this helps,
--David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---