home · contact · privacy
Add test for nonsensical pages triggering 404.
[plomtask] / tests / days.py
index 61a27edbb0d266b892182c241d769ae36a5846b4..7cb0f4fa6c9da13e8064e7e51a8c40e7284c7375 100644 (file)
@@ -91,13 +91,13 @@ 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')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/day?date=FOO')
-        self.assertEqual(self.conn.getresponse().status, 401)
+        self.assertEqual(self.conn.getresponse().status, 400)
         self.conn.request('GET', '/calendar')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/calendar?start=&end=')
@@ -107,4 +107,10 @@ class TestsWithServer(TestCaseWithServer):
         self.conn.request('GET', '/calendar?start=2024-01-01&end=2025-01-01')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/calendar?start=foo')
-        self.assertEqual(self.conn.getresponse().status, 401)
+        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)