Permitting both 404 and 200 responses for some URLs, for now; till we can run tests with a populated database

- Legacy-Id: 242
This commit is contained in:
Henrik Levkowetz 2007-06-05 18:43:48 +00:00
parent 24400ff103
commit 49f8de31b4
2 changed files with 20 additions and 12 deletions

View file

@ -50,13 +50,14 @@ class UrlTestCase(TestCase):
if line and not line.startswith('#'): if line and not line.startswith('#'):
urlspec = line.split() urlspec = line.split()
if len(urlspec) == 2: if len(urlspec) == 2:
code, testurl = urlspec codes, testurl = urlspec
goodurl = None goodurl = None
elif len(urlspec) == 3: elif len(urlspec) == 3:
code, testurl, goodurl = urlspec codes, testurl, goodurl = urlspec
else: else:
raise ValueError("Expected 'HTTP_CODE TESTURL [GOODURL]' in %s line, found '%s'." % (filename, line)) raise ValueError("Expected 'HTTP_CODE TESTURL [GOODURL]' in %s line, found '%s'." % (filename, line))
self.testtuples += [ (code, testurl, goodurl) ] codes = codes.split(",")
self.testtuples += [ (codes, testurl, goodurl) ]
self.testurls += [ testurl ] self.testurls += [ testurl ]
#print "(%s, %s, %s)" % (code, testurl, goodurl) #print "(%s, %s, %s)" % (code, testurl, goodurl)
#print self.testtuples #print self.testtuples
@ -64,7 +65,7 @@ class UrlTestCase(TestCase):
def testCoverage(self): def testCoverage(self):
covered = [] covered = []
patterns = get_patterns(ietf.urls) patterns = get_patterns(ietf.urls)
for code, testurl, goodurl in self.testtuples: for codes, testurl, goodurl in self.testtuples:
for pattern in patterns: for pattern in patterns:
if re.match(pattern, testurl[1:]): if re.match(pattern, testurl[1:]):
covered.append(pattern) covered.append(pattern)
@ -77,14 +78,16 @@ class UrlTestCase(TestCase):
print "Not all the application URLs has test cases." print "Not all the application URLs has test cases."
def testUrls(self): def testUrls(self):
for code, testurl, goodurl in self.testtuples: for codes, testurl, goodurl in self.testtuples:
if code in ["skip", "Skip"]: if codes[0] in ["skip", "Skip"]:
print "Skipping %s" % (testurl) print "Skipping %s" % (testurl)
else: else:
try: try:
response = self.client.get(testurl) response = self.client.get(testurl)
print "Got code %s for %s" % (response.status_code, testurl) code = response.status_code
#self.assertEqual(response.status_code, code, "Unexpected response code (%s) for URL '%s'" % (response.status_code, testurl)) print "Got code %s for %s" % (code, testurl)
if not code in codes:
self.fail("Unexpected response code (%s) for URL '%s'" % (code, testurl))
# TODO: Add comparison with goodurl # TODO: Add comparison with goodurl
except: except:
print "Exception for URL '%s'" % testurl print "Exception for URL '%s'" % testurl

View file

@ -1,7 +1,9 @@
# Broken URLs have been commented out # Broken URLs have been commented out
200 / 200 /
#200 /accounts/ 200 /accounts/
200,404 /accounts/password_change/
200,404 /accounts/profile/
#200 /admin #200 /admin
#200 /announcements/ #200 /announcements/
200 /idindex/ 200 /idindex/
@ -20,6 +22,8 @@
200 /idindex/inddocs/B/ 200 /idindex/inddocs/B/
200 /idindex/inddocs/Y/ 200 /idindex/inddocs/Y/
200 /idindex/otherdocs/iab/ 200 /idindex/otherdocs/iab/
200,404 /idtracker/status/
200,404 /idtracker/last_call/
200 /iesg/telechat/ 200 /iesg/telechat/
200 /iesg/telechat/2006/ 200 /iesg/telechat/2006/
200 /iesg/telechat/2006/feb/ 200 /iesg/telechat/2006/feb/
@ -36,10 +40,11 @@
200 /ipr/new-specific/ 200 /ipr/new-specific/
200 /ipr/new-third-party/ 200 /ipr/new-third-party/
skip /my/ skip /my/
#200 /liaisons/ 200,404 /liaisons/
200,404 /liaisons/managers/
#200 /liaisons/329/ #200 /liaisons/329/
#200 /mailing-lists/area-lists/ 200,404 /mailing-lists/area-lists/
#200 /mailing-lists/nonwg-lists/ 200,404 /mailing-lists/nonwg-lists/
#200 /mailing-lists/nonwg-lists/submit/ #200 /mailing-lists/nonwg-lists/submit/
#200 /mailing-lists/request/ #200 /mailing-lists/request/
#200 /mailing-lists/area-lists/ #200 /mailing-lists/area-lists/