Exemplo n.º 1
0
 def test_same_day(self):
     '''Test time delta within the same day.'''
     date = datetime(year=2016,
                     month=7,
                     day=18,
                     hour=util.OPENING_HOUR,
                     tzinfo=util.LOCAL_TZ)
     td = timedelta(hours=((util.CLOSING_HOUR - util.OPENING_HOUR) % 24) /
                    2)
     after = date + td
     assert util.get_expiration_time(date, td) == after
Exemplo n.º 2
0
 def _next_task(self):
     # type: () -> None
     '''
     Advances to the next task if there is no pending task and alerts the
     user of its existence.
     '''
     self.pending_task = self.tasks.pop(0)
     self.parent.alert_user(self, self.pending_task)
     self._reset_message()
     self._escalation_time = get_expiration_time(datetime.now(tz=pytz.utc),
                                                 ESCALATION_TIME)
     logging.info('Beginning task for {0}'.format(self['name']))
Exemplo n.º 3
0
 def test_next_weekday(self):
     '''Test time delta overnight.'''
     date = datetime(year=2016,
                     month=7,
                     day=18,
                     hour=util.CLOSING_HOUR - 1,
                     tzinfo=util.LOCAL_TZ)
     next_date = datetime(year=2016,
                          month=7,
                          day=19,
                          hour=util.OPENING_HOUR + 1,
                          tzinfo=util.LOCAL_TZ)
     assert util.get_expiration_time(date, timedelta(hours=2)) == next_date
Exemplo n.º 4
0
 def _next_task(self):
     # type: () -> None
     '''
     Advances to the next task if there is no pending task and alerts the
     user of its existence.
     '''
     self.pending_task = self.tasks.pop(0)
     self._bot.alert_user(self, self.pending_task)
     self._reset_message()
     self._escalation_time = get_expiration_time(
         start=datetime.now(tz=pytz.utc),
         ttl=timedelta(minutes=self._bot._escalation_time_mins),
         bot=self._bot)
     logging.info('Beginning task for {0}'.format(self['name']))
Exemplo n.º 5
0
 def test_edge_weekend(self):
     '''Test time delta over a weekend just barely within range.'''
     date = datetime(year=2016,
                     month=7,
                     day=15,
                     hour=util.CLOSING_HOUR - 1,
                     minute=59,
                     second=59,
                     tzinfo=util.LOCAL_TZ)
     td = timedelta(seconds=1)
     after = datetime(year=2016,
                      month=7,
                      day=18,
                      hour=util.OPENING_HOUR,
                      tzinfo=util.LOCAL_TZ)
     assert util.get_expiration_time(date, td) == after