|
33 | 33 | import unittest, os, re |
34 | 34 | from django.test.client import Client |
35 | 35 | from django.conf import settings |
36 | | -from ietf.utils.test_utils import SimpleUrlTestCase, RealDatabaseTest, split_url, read_testurls |
| 36 | +from ietf.utils.test_utils import split_url, read_testurls, TestCase |
37 | 37 | import ietf.urls |
38 | 38 | import ietf.utils.test_runner as test_runner |
39 | 39 |
|
|
60 | 60 | '/drafts/10845/related/', |
61 | 61 | '/public/idindex.cgi?command=id_detail&filename=draft-l3vpn-as4octet-ext-community': |
62 | 62 | '/drafts/draft-l3vpn-as4octet-ext-community/', |
| 63 | + # non-ASCII parameter |
| 64 | + '/public/pidtracker.cgi?command=view_id&dTag=11171%D182&rfc_flag=0': |
| 65 | + '/idtracker/', |
| 66 | + '/idtracker/': '/doc/', |
63 | 67 |
|
64 | 68 | # ipr |
65 | 69 |
|
|
86 | 90 |
|
87 | 91 | } |
88 | 92 |
|
89 | | -class RedirectsTestCase(unittest.TestCase, RealDatabaseTest): |
90 | | - def setUp(self): |
91 | | - self.setUpRealDatabase() |
92 | | - def tearDown(self): |
93 | | - self.tearDownRealDatabase() |
94 | | - |
95 | | - def testRedirects(self): |
96 | | - print " Testing redirects" |
97 | | - |
98 | | - c = Client() |
| 93 | +class RedirectsTests(TestCase): |
| 94 | + def test_redirects(self): |
99 | 95 | for src, dst in REDIRECT_TESTS.items(): |
100 | 96 | baseurl, args = split_url(src) |
101 | | - try: |
102 | | - response = c.get(baseurl, args) |
103 | | - self.assert_(str(response.status_code).startswith("3")) |
104 | | - location = response['Location'] |
105 | | - if location.startswith("http://testserver/"): |
106 | | - location = location[17:] |
107 | | - self.assertEqual(location, dst) |
108 | | - print "OK "+src |
109 | | - except: |
110 | | - print "Fail "+src |
111 | | - raise |
| 97 | + response = self.client.get(baseurl, args) |
| 98 | + self.assertTrue(str(response.status_code).startswith("3")) |
| 99 | + location = response['Location'] |
| 100 | + if location.startswith("http://testserver/"): |
| 101 | + location = location[17:] |
| 102 | + self.assertEqual(location, dst, (src, dst, location)) |
112 | 103 |
|
113 | 104 | def get_patterns(module): |
114 | 105 | all = [] |
@@ -155,9 +146,13 @@ def testUrlCoverage(self): |
155 | 146 | else: |
156 | 147 | print "All URLs are included in some testurl.list" |
157 | 148 |
|
158 | | -class MainUrlTestCase(SimpleUrlTestCase): |
159 | | - def testUrls(self): |
160 | | - self.doTestUrls(__file__) |
| 149 | +class MainUrlTests(TestCase): |
| 150 | + def test_urls(self): |
| 151 | + self.assertEqual(self.client.get("/_doesnotexist/").status_code, 404) |
| 152 | + self.assertEqual(self.client.get("/sitemap.xml").status_code, 200) |
| 153 | + # Google webmaster tool verification page |
| 154 | + self.assertEqual(self.client.get("/googlea30ad1dacffb5e5b.html").status_code, 200) |
| 155 | + |
161 | 156 |
|
162 | 157 | def get_templates(): |
163 | 158 | templates = set() |
|
0 commit comments