home · contact · privacy
Add test for nonsensical pages triggering 404.
[plomtask] / tests / days.py
index 06e4302d71aaba58867e961506806a792c1fe807..7cb0f4fa6c9da13e8064e7e51a8c40e7284c7375 100644 (file)
@@ -91,7 +91,7 @@ class TestsWithServer(TestCaseWithServer):
     """Tests against our HTTP server/handler (and database)."""
 
     def test_do_GET(self) -> None:
-        """Test /day and /calendar response codes."""
+        """Test /day and /calendar response codes, and / redirect."""
         self.conn.request('GET', '/day')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/day?date=3000-01-01')
@@ -108,3 +108,9 @@ class TestsWithServer(TestCaseWithServer):
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/calendar?start=foo')
         self.assertEqual(self.conn.getresponse().status, 400)
+        self.conn.request('GET', '/')
+        response = self.conn.getresponse()
+        self.assertEqual(response.status, 302)
+        self.assertEqual(response.getheader('Location'), '/day')
+        self.conn.request('GET', '/foo')
+        self.assertEqual(self.conn.getresponse().status, 404)