- def test_do_GET(self):
- """Test /day and /calendar response codes."""
- http_conn = HTTPConnection(*self.httpd.server_address)
- http_conn.request('GET', '/day')
- self.assertEqual(http_conn.getresponse().status, 200)
- http_conn.request('GET', '/day?date=3000-01-01')
- self.assertEqual(http_conn.getresponse().status, 200)
- http_conn.request('GET', '/day?date=FOO')
- self.assertEqual(http_conn.getresponse().status, 400)
- http_conn.request('GET', '/calendar')
- self.assertEqual(http_conn.getresponse().status, 200)
- http_conn.request('GET', '/calendar?start=&end=')
- self.assertEqual(http_conn.getresponse().status, 200)
- http_conn.request('GET', '/calendar?start=today&end=today')
- self.assertEqual(http_conn.getresponse().status, 200)
- http_conn.request('GET', '/calendar?start=2024-01-01&end=2025-01-01')
- self.assertEqual(http_conn.getresponse().status, 200)
- http_conn.request('GET', '/calendar?start=foo')
- self.assertEqual(http_conn.getresponse().status, 400)
+ def test_do_GET(self) -> None:
+ """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, 400)
+ self.conn.request('GET', '/calendar')
+ self.assertEqual(self.conn.getresponse().status, 200)
+ self.conn.request('GET', '/calendar?start=&end=')
+ self.assertEqual(self.conn.getresponse().status, 200)
+ self.conn.request('GET', '/calendar?start=today&end=today')
+ self.assertEqual(self.conn.getresponse().status, 200)
+ 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, 400)
+ self.conn.request('GET', '/')
+ response = self.conn.getresponse()
+ self.assertEqual(response.status, 302)
+ self.assertEqual(response.getheader('Location'), '/day')