def do_POST_day(self, conn: DatabaseConnection, date: str, postvars: dict):
"""Update or insert Day of date and fields defined in postvars."""
- comment = postvars['comment'][0]
day = Day.by_date(conn, date, create=True)
- day.comment = comment
+ day.comment = postvars['comment'][0]
day.save(conn)
def _init_handling(self):
today.save(self.db_conn)
self.assertEqual(Day.all(self.db_conn, ('today', 'today')), [today])
- def test_Day_comment(self):
- """Test Day.comment."""
- 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')
-
def test_Day_neighbor_dates(self):
"""Test Day.prev_date and Day.next_date."""
self.assertEqual(Day('2024-01-01').prev_date, '2023-12-31')