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):
"""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()