annotate examples/project/zoo/test_urlconf.py @ 9:35178e70f1cd

urls support in testcase objects
author Victor Ng <victor@monkeybean.ca>
date Thu, 28 Aug 2008 13:33:58 -0400
parents
children 9af906a73061
rev   line source
9
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
1 from django.test import TestCase
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
2 from django.test.client import Client
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
3
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
4 class TestStandardUrlConf(TestCase):
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
5 def test_index(self):
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
6 '''
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
7 We're using the standard ROOT_URLCONF, so we need to
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
8 pass in /zoo/, just the empty string
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
9 '''
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
10 c = Client()
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
11 resp = c.get('')
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
12 assert resp.status_code == 500
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
13
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
14 c = Client()
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
15 resp = c.get('/zoo/')
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
16 assert "Just a title" in resp.content
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
17 assert "foobar" in resp.content
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
18
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
19 class TestCustomUrlConf(TestCase):
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
20 urls = 'zoo.urls'
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
21
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
22 def test_index(self):
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
23 '''
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
24 We're customizing the ROOT_URLCONF with zoo.urls,
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
25 so we do *not* need to pass in /zoo/, just the empty string
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
26 '''
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
27 c = Client()
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
28 resp = c.get('')
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
29 assert "Just a title" in resp.content
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
30 assert "foobar" in resp.content
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
31
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
32 c = Client()
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
33 resp = c.get('/zoo/')
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
34 assert resp.status_code == 500
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
35
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
36
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
37
35178e70f1cd urls support in testcase objects
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
38