home · contact · privacy
Refactor tests, expand Days testing.
[plomtask] / plomtask / days.py
index a924bbfeadd2bd895d2f21ac4b7487305fbe771f..0bd942cbd8804b8900a3271b9f4f0e4881f105ec 100644 (file)
@@ -12,6 +12,7 @@ class Day(BaseModel[str]):
     """Individual days defined by their dates."""
     table_name = 'days'
     to_save = ['comment']
+    can_create_by_id = True
 
     def __init__(self, date: str, comment: str = '') -> None:
         id_ = valid_date(date)
@@ -40,13 +41,9 @@ class Day(BaseModel[str]):
         return day
 
     @classmethod
-    def by_id(cls,
-              db_conn: DatabaseConnection, id_: str | None,
-              create: bool = False,
-              ) -> Day:
+    def by_id(cls, db_conn: DatabaseConnection, id_: str) -> Day:
         """Extend BaseModel.by_id checking for new/lost .todos."""
-        day = super().by_id(db_conn, id_, create)
-        assert day.id_ is not None
+        day = super().by_id(db_conn, id_)
         if day.id_ in Todo.days_to_update:
             Todo.days_to_update.remove(day.id_)
             day.todos = Todo.by_date(db_conn, day.id_)