+
+ def test_Day_comment(self):
+ """Test Day.by_date()."""
+ self.assertEqual(None, Day.by_date(self.db_conn, '2024-01-01'))
+ d1 = Day('2024-01-01')
+ d1.save(self.db_conn)
+ day_retrieved = Day.by_date(self.db_conn, d1.date)
+ self.assertEqual(day_retrieved.comment, '')
+ d2 = Day('2024-01-02', 'foo')
+ d2.save(self.db_conn)
+ day_retrieved = Day.by_date(self.db_conn, d2.date)
+ self.assertEqual(day_retrieved.comment, 'foo')
+
+
+class TestsWithServer(TestsWithDB):
+ """Tests against our HTTP server/handler (and database)."""
+
+ def setUp(self):
+ super().setUp()
+ self.httpd = TaskServer(self.db_file, ('localhost', 0), TaskHandler)
+ self.server_thread = Thread(target=self.httpd.serve_forever)
+ self.server_thread.daemon = True
+ self.server_thread.start()
+
+ def test_do_GET_day(self):
+ """Test /day response."""
+ conn = HTTPConnection(*self.httpd.server_address)
+ conn.request('GET', '/day')
+ response = conn.getresponse()
+ self.assertEqual(response.status, 200)
+
+ def tearDown(self):
+ self.httpd.shutdown()
+ self.httpd.server_close()
+ self.server_thread.join()
+ super().tearDown()