def test_from_json(self): schedule_config = WorkflowScheduleConfig.from_json(WorkflowScheduleConfigTestCase._SCHEDULE_JSON) self.assertEqual(["*****@*****.**", "*****@*****.**"], schedule_config.emails) self.assertEqual("DELAY", schedule_config.overrun_policy) self.assertEqual("1d", schedule_config.recurrence) self.assertEqual("2012-01-01", schedule_config.start_date) self.assertEqual("00.00.01.000", schedule_config.time) self.assertEqual("some_workflow", schedule_config.workflow)
def test_put_schedule(self): schedule_config = WorkflowScheduleConfig.from_json( _SCHEDULE_TEMPLATE % '1w') self._repository.put_schedule(schedule_config) self.assertEqual(1, len(self._repository.configs)) self.assertEqual( _SCHEDULE_TEMPLATE % '1w', self._repository.configs['/workflow/some_workflow/schedule'])
def test_format(self): schedule_config = WorkflowScheduleConfig.from_json(WorkflowScheduleConfigTestCase._SCHEDULE_JSON) formatted_config = schedule_config.format() self.assertEqual(["*****@*****.**", "*****@*****.**"], formatted_config["emails"]) self.assertEqual("DELAY", formatted_config["overrun_policy"]) self.assertEqual("1d", formatted_config["recurrence"]) self.assertEqual("2012-01-01", formatted_config["start_date"]) self.assertEqual("00.00.01.000", formatted_config["time"]) self.assertEqual("some_workflow", formatted_config["workflow"])
def test_from_json(self): schedule_config = WorkflowScheduleConfig.from_json( WorkflowScheduleConfigTestCase._SCHEDULE_JSON) self.assertEqual(['*****@*****.**', '*****@*****.**'], schedule_config.emails) self.assertEqual('DELAY', schedule_config.overrun_policy) self.assertEqual('1d', schedule_config.recurrence) self.assertEqual('2012-01-01', schedule_config.start_date) self.assertEqual('00.00.01.000', schedule_config.time) self.assertEqual('some_workflow', schedule_config.workflow)
def get_schedule(self, workflow): """Retrieve schedule config for a given workflow. Args: workflow: The workflow name whose schedule should be retrieved. Returns: The schedule config. """ path = Path(workflow=workflow) schedule_json = self._get_config(path.get_schedule_path()) return WorkflowScheduleConfig.from_json(schedule_json)
def test_format(self): schedule_config = WorkflowScheduleConfig.from_json( WorkflowScheduleConfigTestCase._SCHEDULE_JSON) formatted_config = schedule_config.format() self.assertEqual(['*****@*****.**', '*****@*****.**'], formatted_config['emails']) self.assertEqual('DELAY', formatted_config['overrun_policy']) self.assertEqual('1d', formatted_config['recurrence']) self.assertEqual('2012-01-01', formatted_config['start_date']) self.assertEqual('00.00.01.000', formatted_config['time']) self.assertEqual('some_workflow', formatted_config['workflow'])
def test_delete_schedule(self): schedule_config = WorkflowScheduleConfig.from_json( _SCHEDULE_TEMPLATE % 100) self._repository.put_schedule(schedule_config) self._repository.delete_schedule('some_workflow') self.assertEqual({}, self._repository.configs)