def test_update_scheduler(self): task = ScheduledTask(name='test', task_trigger=self.date_trigger) update = {'task_trigger': {'type': 'interval', 'args': {'hours': 1, 'weeks': 4}}} task.update(update) self.assertEqual(task.trigger_type, 'interval') self.assertDictEqual(json.loads(task.trigger_args), {'hours': 1, 'weeks': 4}) self.assertSchedulerWorkflowsRunningEqual(workflows=None)
def test_update_scheduler_invalid_scheduler(self): task = ScheduledTask(name='test', task_trigger=self.date_trigger) update = {'name': 'renamed', 'task_trigger': {'type': 'interval', 'args': {'invalid': 1, 'weeks': 4}}} with self.assertRaises(InvalidTriggerArgs): task.update(update) self.assertEqual(task.name, 'test') self.assertSchedulerWorkflowsRunningEqual(workflows=None)
def test_update_workflows_with_existing_workflows_running_add_and_remove(self): workflows = ['a', 'b', 'c', 'd'] task = ScheduledTask(name='test', task_trigger=self.date_trigger, workflows=['b', 'c', 'd'], status='running') update = {'workflows': ['a', 'b']} task.update(update) self.assertSetEqual({workflow.workflow_id for workflow in task.workflows}, {'a', 'b'}) self.assertSchedulerWorkflowsRunningEqual(['a', 'b'])
def test_update_workflows_none_existing_running(self): workflows = ['a', 'b', 'c', 'd'] task = ScheduledTask(name='test', task_trigger=self.date_trigger, status='running') update = {'workflows': ['a', 'b', 'c']} task.update(update) self.assertListEqual([workflow.workflow_id for workflow in task.workflows], ['a', 'b', 'c']) self.assertSchedulerWorkflowsRunningEqual(['a', 'b', 'c'])
def test_update_workflows_with_existing_workflows_stopped(self): task = ScheduledTask(name='test', workflows=['b', 'c', 'd']) update = {'workflows': ['a', 'b', 'c']} task.update(update) self.assertSetEqual( {workflow.workflow_id for workflow in task.workflows}, {'a', 'b', 'c'}) self.assertSchedulerWorkflowsRunningEqual(workflows=None)
def test_update_workflows_none_existing_stopped(self): task = ScheduledTask(name='test', status='stopped') update = {'workflows': ['a', 'b', 'c']} task.update(update) self.assertListEqual( [workflow.workflow_id for workflow in task.workflows], ['a', 'b', 'c']) self.assertSchedulerWorkflowsRunningEqual(workflows=None)
def test_update_name_desc_only(self): task = ScheduledTask(name='test') update = {'name': 'updated_name', 'description': 'desc'} task.update(update) self.assertEqual(task.name, 'updated_name') self.assertEqual(task.description, 'desc')
def test_update_workflows_with_existing_workflows_stopped(self): task = ScheduledTask(name='test', workflows=['b', 'c', 'd']) update = {'workflows': ['a', 'b', 'c']} task.update(update) self.assertSetEqual({workflow.workflow_id for workflow in task.workflows}, {'a', 'b', 'c'}) self.assertSchedulerWorkflowsRunningEqual(workflows=None)
def test_update_workflows_none_existing_stopped(self): task = ScheduledTask(name='test', status='stopped') update = {'workflows': ['a', 'b', 'c']} task.update(update) self.assertListEqual([workflow.workflow_id for workflow in task.workflows], ['a', 'b', 'c']) self.assertSchedulerWorkflowsRunningEqual(workflows=None)
def test_update_name_desc_only(self): task = ScheduledTask(name='test') update = {'name': 'updated_name', 'description': 'desc'} task.update(update) self.assertEqual(task.name, 'updated_name') self.assertEqual(task.description, 'desc')