On 20 Aug 2014, at 12:33, pyramidX <[email protected]> wrote:
> Thanks, that clarifies things. You're right that an integration test is more > the way to go rather than trying to unit test this. > > What is the most straightforward way to run integration tests that span > multiple requests? I could do 1 DummyRequest to log in, then take those > Set-Cookie headers on the response and create a new DummyRequest and manually > turn them into Cookie headers, but this seems error-prone. It would be me > trying to do the work of a web client (such as browser) manually (i.e. the > part you mentioned "Browser will process the response from the view in step > 2, update its cookies and send a new request."). For example, maybe I'll set > a cookie that shouldn't have been set because of the cookie's "path" > attribute, expiry time, or something else I didn't consider (but a browser or > proper web client would). > > request1 = DummyRequest(post=........) > response1 = views.login(request1) > # What's the least error-prone way of turning all the Set-Cookie's from > response1 into Cookie's in request2? > request2 = DummyRequest(post=.........) > response2 = views.someotherview(request2) > > I took a look at the Integration testing and Functional testing sections at > http://docs.pylonsproject.org/docs/pyramid/en/latest/narr/testing.html but > they don't mention such a workflow. Is my only option to use something at a > much higher level like Selenium? Hopefully not, as I like the idea of > asserting things at the level of the pyramid view (like asserting with a dict > that is returned by a view for example). What I'd like to do is write some > use case integration tests, like: Use functional tests: http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/testing.html#creating-functional-tests . They are designed for this very purpose. Selenium is useful if you also want to take the next step and verify in-browser rendering and javascript. Wichert. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
