def process_notifications(self): """Changes notification status from CREATED to PENDING if it's time to show notification""" for notification in Notification.select().where( Notification.status == NotificationStatus.CREATED.value).join( Task).where(Task.id == Notification.task_id): task = Task.get(Task.id == notification.task_id) if (task.start_time - datetime.timedelta( seconds=notification.relative_start_time) ) < datetime.datetime.now(): notification.status = NotificationStatus.PENDING.value notification.save()
def test_updates_task(self): task_with_id = self.task_storage.create(self.task) task_with_id.title = "Do something great" self.task_storage.update(task_with_id) task_from_db = Task.get(Task.id == task_with_id.id) self.assertEqual(task_from_db.title, "Do something great")
def get_by_id(self, task_id): try: return self.to_task_instance(Task.get(Task.id == task_id)) except DoesNotExist: return None