From 0c177c33e30989f0d944307cffcb109f5d88fe2f Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Sun, 6 Mar 2011 15:34:08 -0500 Subject: [PATCH] completed basic WebTEst and unittest section --- docs/source/testing.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/source/testing.rst b/docs/source/testing.rst index be501f7..0b2e670 100644 --- a/docs/source/testing.rst +++ b/docs/source/testing.rst @@ -63,6 +63,28 @@ exactly as if your application was really running via an HTTP server. Using WebTest with a UnitTest ----------------------------- +Once you have a ``setUp`` method with your Pecan configuration loaded you have +a wealth of actions provided within the test class to interact with your Pecan +application:: + * POST => self.app.post + * GET => self.app.get + * DELETE => self.app.delete + * PUT => self.app.put +For example, if I wanted to assert that I can get the root of my application, +I would probably do something similar to this: + + response = self.app.get('/') + assert response.status_int == 200 + +If you are expecting error responses from your application, you should make +sure that you pass the `expect_errors` flag and set it to True:: + + response = self.app.get('/url/does/not/exist', expect_errors=True) + assert response.status_int == 404 + +If you would like to dig in to more examples in how to test and verify more +actions, make sure you take a look at the +`WebTest documentation `_