Skip to content

Commit f1a34fa

Browse files
committed
Rewrite main url tests and redirects test to use the test database
- Legacy-Id: 6837
1 parent 77fc3ec commit f1a34fa

2 files changed

Lines changed: 20 additions & 41 deletions

File tree

ietf/redirects/tests.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import unittest, os, re
3434
from django.test.client import Client
3535
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
3737
import ietf.urls
3838
import ietf.utils.test_runner as test_runner
3939

@@ -60,6 +60,10 @@
6060
'/drafts/10845/related/',
6161
'/public/idindex.cgi?command=id_detail&filename=draft-l3vpn-as4octet-ext-community':
6262
'/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/',
6367

6468
# ipr
6569

@@ -86,29 +90,16 @@
8690

8791
}
8892

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):
9995
for src, dst in REDIRECT_TESTS.items():
10096
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))
112103

113104
def get_patterns(module):
114105
all = []
@@ -155,9 +146,13 @@ def testUrlCoverage(self):
155146
else:
156147
print "All URLs are included in some testurl.list"
157148

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+
161156

162157
def get_templates():
163158
templates = set()

ietf/redirects/testurl.list

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)