- date = '2024-01-01'
- comment = 'comment'
- day = Day(date, comment)
- # check object init itself doesn't store anything yet
- self.assertEqual({}, Day.get_cache())
- self.assertEqual([], Day.all(self.db_conn))
- # check saving stores in cache and DB
- day.save(self.db_conn)
- assert isinstance(day.id_, str)
- for row in self.db_conn.row_where(Day.table_name, 'id', day.id_):
- self.assertEqual(day, Day.from_table_row(self.db_conn, row))
- self.assertEqual({day.id_: day}, Day.get_cache())
- # check attributes set properly (and not unset by saving)
- self.assertEqual(day.id_, date)
- self.assertEqual(day.comment, comment)
+ kwargs = {'date': self.default_ids[0], 'comment': 'foo'}
+ self.check_saving_and_caching(**kwargs)
+
+ def test_Day_from_table_row(self) -> None:
+ """Test .from_table_row() properly reads in class from DB"""
+ self.check_from_table_row()