Previously Mike Orr wrote:
> 
> On Sat, Jun 28, 2008 at 7:19 AM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Jun 28, 7:18 am, "Shannon -jj Behrens" <[EMAIL PROTECTED]> wrote:
> >
> >>  * Use one action to put something into the session and then another
> >> to make use of the session.  It's a work flow.
> >
> > I've always thought that Pylons should have something that does that.
> 
> Well, JJ is right in a way.  The session is supposed to hold state
> between web requests.  So it makes sense that you'd set it up via web
> requests.  Just like an application that requires login; you have to
> do the login request at the beginning of each test.
> 
> But I can also see the point of giving Pylons some premade session
> data, like a test with premade database data.  In Mechanize you can
> precreate a CookieJar and seed it with cookies, and pass that to your
> fake browser object.  You can also save the cookie jar to a file and
> reuse it later.

I found that when you are writing unit tests it is essential to be able to
stuff data into session, c and request. I'm using a base class for
unittests which looks like this:

    from unittest import TestCase
    from paste.registry import Registry
    import pylons
    from pylons.util import ContextObj
    from pylons.controllers.util import Request


    class PylonsTestCase(TestCase):
        """A basic test case which allows access to pylons.c and pylons.request.
        """

        def setUp(self):
            self.registry=Registry()
            self.registry.prepare()

            self.context_obj=ContextObj()
            self.registry.register(pylons.c, self.context_obj)

            self.request_obj=Request(dict(HTTP_HOST="nohost"))
            self.registry.register(pylons.request, self.request_obj)


it probably isn't difficult to add session support to that.

Wichert.

-- 
Wichert Akkerman <[EMAIL PROTECTED]>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to