def test_cancel_timer(self): """ Make sure we a cancel a timer """ # set up a timer that is due in the past timer = publish_timed_notification( msg=self.msg, send_at=datetime.now(pytz.UTC) - timedelta(days=1), scope_name='user', scope_context={'range': 1} ) cancel_timed_notification(timer.name) # fetch the timer again from DB updated_timer = self.store.get_notification_timer(timer.name) # is_active = False self.assertFalse(updated_timer.is_active) poll_and_execute_timers() # fetch the timer from the DB as it should be updated updated_timer = self.store.get_notification_timer(timer.name) # should not have been executed self.assertIsNone(updated_timer.executed_at)
def test_cancel_timer(self): """ Make sure we a cancel a timer """ # set up a timer that is due in the past timer = publish_timed_notification( msg=self.msg, send_at=datetime.now(pytz.UTC) - timedelta(days=1), scope_name='user', scope_context={'range': 1} ) cancel_timed_notification(timer.name) # fetch the timer again from DB updated_timer = self.store.get_notification_timer(timer.name) # is_active = False self.assertFalse(updated_timer.is_active) poll_and_execute_timers() # fetch the timer from the DB as it should be updated updated_timer = self.store.get_notification_timer(timer.name) # should not have been executed self.assertIsNone(updated_timer.executed_at)
def test_cancel_non_existing_timer(self): """ Make sure canceling a time that does not exist raises a ItemNotFoundError """ raised = False try: cancel_timed_notification('no-exist') except ItemNotFoundError: raised = True self.assertFalse(raised)
def test_cancel_non_existing_timer(self): """ Make sure canceling a time that does not exist raises a ItemNotFoundError """ raised = False try: cancel_timed_notification('no-exist') except ItemNotFoundError: raised = True self.assertFalse(raised)