diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index 395905b..5130c9c 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -507,10 +507,10 @@ class User: user_phone: str password_hash: str api_key: str - notify_email: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? - notify_whatsapp: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? - notify_signal: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? - notify_popup: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? + notify_email: bool + notify_whatsapp: bool + notify_signal: bool + notify_popup: bool created: datetime modified: datetime diff --git a/src/server/BreCal/validators/time_logic.py b/src/server/BreCal/validators/time_logic.py index 8ebad56..8a0e592 100644 --- a/src/server/BreCal/validators/time_logic.py +++ b/src/server/BreCal/validators/time_logic.py @@ -76,8 +76,17 @@ class TimeLogic(): minute_delta = delta / np.timedelta64(1, unit) return minute_delta - def time_delta_from_now_to_tgt(self, tgt_time, unit="m"): - return self.time_delta(datetime.datetime.now(), tgt_time=tgt_time, unit=unit) + def time_delta_from_now_to_tgt(self, tgt_time, unit="m", now_time=None): + """ + This method computes the timedelta between a target time {tgt_time} and the current timestamp. For the purpose of + reproducibility and testing, the current timestamp {now_time} can be overwritten. The default behaviour uses the + datetime.now() function. + """ + if now_time is None: + return self.time_delta(datetime.datetime.now(), tgt_time=tgt_time, unit=unit) + else: + assert isinstance(now_time,datetime.datetime), f"incorrect type for now_time: {now_time} with type {type(now_time)}" + return self.time_delta(now_time, tgt_time=tgt_time, unit=unit) def time_inbetween(self, query_time:datetime.datetime, start_time:datetime.datetime, end_time:datetime.datetime) -> bool: """