From 508024e09c84da4e11595e900586f3d7f79094d2 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 20 Mar 2024 02:37:20 +0100
Subject: [PATCH] On GET /day with unknown (but valid) "?date=", create new
 Day.

---
 plomtask/http.py   | 2 +-
 tests/test_days.py | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/plomtask/http.py b/plomtask/http.py
index 01a949e..be7affa 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -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):
diff --git a/tests/test_days.py b/tests/test_days.py
index 35380c6..04f667b 100644
--- a/tests/test_days.py
+++ b/tests/test_days.py
@@ -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()
-- 
2.30.2