home · contact · privacy
On GET /day with unknown (but valid) "?date=", create new Day.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 20 Mar 2024 01:37:20 +0000 (02:37 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 20 Mar 2024 01:37:20 +0000 (02:37 +0100)
plomtask/http.py
tests/test_days.py

index 01a949e019eddbf9919f333d252a05aeb7dcd4e7..be7affac268f23eecd5e0c232d9c17e2ac5bfeff 100644 (file)
@@ -48,7 +48,7 @@ class TaskHandler(BaseHTTPRequestHandler):
 
     def do_GET_day(self, conn: DatabaseConnection, date: str):
         """Show single Day."""
-        day = Day.by_date(conn, date)
+        day = Day.by_date(conn, date, create=True)
         return self.server.jinja.get_template('day.html').render(day=day)
 
     def do_POST(self):
index 35380c690f65c5fa18029311f5c7446667c1f116..04f667bfb88dbbae58087399dde3aae1daf251a7 100644 (file)
@@ -116,8 +116,9 @@ class TestsWithServer(TestsWithDB):
         """Test /day response."""
         conn = HTTPConnection(*self.httpd.server_address)
         conn.request('GET', '/day')
-        response = conn.getresponse()
-        self.assertEqual(response.status, 200)
+        self.assertEqual(conn.getresponse().status, 200)
+        conn.request('GET', '/day?date=FOO')
+        self.assertEqual(conn.getresponse().status, 400)
 
     def tearDown(self):
         self.httpd.shutdown()