From deecbc9da3930faa2aa5ac1997a0c5f91c9cbd34 Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Mon, 11 Jun 2007 09:36:45 +0000
Subject: [PATCH] Don't list URLs which have explicit tests as Skipped during
 the fallback URL test.  - Legacy-Id: 307

---
 ietf/tests.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/ietf/tests.py b/ietf/tests.py
index 7ef4627fc..ea1279968 100644
--- a/ietf/tests.py
+++ b/ietf/tests.py
@@ -84,6 +84,9 @@ class UrlTestCase(TestCase):
             if "testurls.list" in files:
                 self.testtuples += read_testurls(root+"/testurls.list")
         self.testurls = [ tuple[1] for tuple in self.testtuples ]
+
+        # extract application urls:
+        self.patterns = get_patterns(ietf.urls)
         # Use the default database for the url tests, instead of the test database
         self.testdb = settings.DATABASE_NAME
         connection.close()
@@ -98,16 +101,15 @@ class UrlTestCase(TestCase):
         
     def testCoverage(self):
         covered = []
-        patterns = get_patterns(ietf.urls)
         for codes, testurl, goodurl in self.testtuples:
-            for pattern in patterns:
+            for pattern in self.patterns:
                 if re.match(pattern, testurl[1:]):
                     covered.append(pattern)
         # We should have at least one test case for each url pattern declared
         # in our Django application:
         #self.assertEqual(set(patterns), set(covered), "Not all the
         #application URLs has test cases.  The missing are: %s" % (list(set(patterns) - set(covered))))        
-        if not set(patterns) == set(covered):
+        if not set(self.patterns) == set(covered):
             #print "Not all the application URLs has test cases.  The missing are: \n   %s" % ("\n   ".join(list(set(patterns) - set(covered))))
             print "Not all the application URLs has test cases."
 
@@ -183,18 +185,17 @@ class UrlTestCase(TestCase):
         self.doUrlsTest(self.testtuples)
 
     def testUrlsFallback(self):
-        patterns = get_patterns(ietf.urls)
+        print "\nFallback: Test access to URLs which don't have an explicit test entry:"
         lst = []
-        for pattern in patterns:
+        for pattern in self.patterns:
             if pattern.startswith("^") and pattern.endswith("$"):
                 url = "/"+pattern[1:-1]
                 # if there is no variable parts in the url, test it
                 if re.search("^[-a-z0-9./_]*$", url) and not url in self.testurls and not url.startswith("/admin/"):
                     lst.append((["200"], url, None))
                 else:
-                    lst.append((["skip"], url, None))
+                    print "Test exists for %s" % (url)
             else:
                 lst.append((["Skip"], url, None))
             
-        print "\nTesting non-listed URLs:"
         self.doUrlsTest(lst)