Esempio n. 1
0
    def test_schedule_to_timestamp_without_start_date(self):
        # utcnow cannot be monkey patched so we need to add a work around.
        datetime_now = datetime.datetime(2012, 1, 2, 0, 1, 0, 0, pytz.utc)
        Date = collections.namedtuple('date', 'year,month,day')
        date = Date(year=2012, month=1, day=2)
        with mock.patch(
                'pinball.parser.utils.datetime.datetime') as datetime_mock:
            datetime_mock.utcnow.return_value = date
            datetime_mock.return_value = datetime_now

            # 1325462460 = 02 Jan 2012 00:01:00 UTC
            self.assertEqual(1325462460, schedule_to_timestamp('00.00.01.000'))
Esempio n. 2
0
    def test_schedule_to_timestamp_without_start_date(self):
        # utcnow cannot be monkey patched so we need to add a work around.
        datetime_now = datetime.datetime(2012, 1, 2, 0, 1, 0, 0, pytz.utc)
        Date = collections.namedtuple('date', 'year,month,day')
        date = Date(year=2012, month=1, day=2)
        with mock.patch('pinball.parser.utils.datetime.datetime'
                        ) as datetime_mock:
            datetime_mock.utcnow.return_value = date
            datetime_mock.return_value = datetime_now

            # 1325462460 = 02 Jan 2012 00:01:00 UTC
            self.assertEqual(1325462460, schedule_to_timestamp('00.00.01.000'))
 def get_schedule_token(self, workflow):
     schedule_config = self._repository.get_schedule(workflow)
     timestamp = schedule_to_timestamp(schedule_config.time,
                                       schedule_config.start_date)
     recurrence = recurrence_str_to_sec(schedule_config.recurrence)
     overrun_policy = OverrunPolicy.from_string(
         schedule_config.overrun_policy)
     schedule = WorkflowSchedule(
         next_run_time=timestamp,
         recurrence_seconds=recurrence,
         overrun_policy=overrun_policy,
         workflow=schedule_config.workflow,
         emails=schedule_config.emails,
         #TODO(mao): to make it flexible that allow users specify through UI
         max_running_instances=PinballConfig.DEFAULT_MAX_WORKFLOW_RUNNING_INSTANCES)
     schedule.advance_next_run_time()
     timestamp = schedule.next_run_time
     token_name = (
         Name(workflow=schedule_config.workflow
              ).get_workflow_schedule_token_name())
     return Token(name=token_name, owner='parser',
                  expirationTime=timestamp,
                  data=pickle.dumps(schedule))
 def get_schedule_token(self, workflow):
     schedule_config = self._repository.get_schedule(workflow)
     timestamp = schedule_to_timestamp(schedule_config.time,
                                       schedule_config.start_date)
     recurrence = recurrence_str_to_sec(schedule_config.recurrence)
     overrun_policy = OverrunPolicy.from_string(
         schedule_config.overrun_policy)
     schedule = WorkflowSchedule(
         next_run_time=timestamp,
         recurrence_seconds=recurrence,
         overrun_policy=overrun_policy,
         workflow=schedule_config.workflow,
         emails=schedule_config.emails,
         #TODO(mao): to make it flexible that allow users specify through UI
         max_running_instances=PinballConfig.
         DEFAULT_MAX_WORKFLOW_RUNNING_INSTANCES)
     schedule.advance_next_run_time()
     timestamp = schedule.next_run_time
     token_name = (Name(workflow=schedule_config.workflow).
                   get_workflow_schedule_token_name())
     return Token(name=token_name,
                  owner='parser',
                  expirationTime=timestamp,
                  data=pickle.dumps(schedule))
Esempio n. 5
0
 def test_schedule_to_timestamp_with_start_date(self):
     # 1325376000 = 01 Jan 2012 00:00:00 UTC
     self.assertEqual(1325376000,
                      schedule_to_timestamp('00.00.01.000', '2012-01-01'))
Esempio n. 6
0
 def test_schedule_to_timestamp_with_start_date(self):
     # 1325376000 = 01 Jan 2012 00:00:00 UTC
     self.assertEqual(1325376000, schedule_to_timestamp('00.00.01.000',
                                                        '2012-01-01'))