views:

53

answers:

1

I was reading the Rails testing doc and it looks quite comprehensive in explaining the different type of tests. I also noticed the section on Testing Routes. Does anyone know how I can do that in Django/Python? I have a bunch of web sites with some common urls that I need to test. Here's how it's done in Ruby:

def test_should_route_to_post 
  assert_routing '/posts/1', { :controller => "posts", :action => "show", :id => "1" }
end
+1  A: 

Django does have a fairly extensive library for testing Django web apps. The details of testing are a bit beyond the scope of this answer, but you can read the relevant docs about testing Django applications for more details. Particularly, I think you'll be interested in the sections on making requests and testing responses, which allow you to make requests to URLs (for the purposes of testing), and test the responses. Django also has a TestCase subclass that includes assertions specifically designed for use with HTTP requests and responses.

mipadi