Test directory redirect.
authorEmil Mikulic <emikulic@gmail.com>
Sun, 1 May 2011 09:13:25 +0000 (19:13 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Sun, 28 Apr 2013 10:56:46 +0000 (20:56 +1000)
devel/test.py

index d75b343..541822a 100755 (executable)
@@ -151,6 +151,21 @@ def setUpModule():
         ]:
         makeSimpleCases(*args)
 
+class TestDirRedirect(TestHelper):
+    def setUp(self):
+        self.url = "/mydir"
+        self.fn = WWWROOT + self.url
+        os.mkdir(self.fn)
+
+    def tearDown(self):
+        os.rmdir(self.fn)
+
+    def test_dir_redirect(self):
+        resp = Conn().get(self.url)
+        status, hdrs, body = parse(resp)
+        self.assertContains(status, "301 Moved Permanently")
+        self.assertEquals(hdrs["Location"], self.url+"/") # trailing slash
+
 class TestFileGet(TestHelper):
     def setUp(self):
         self.datalen = 2345