def test_load_recovers_tasks_index(self): scheduler = luigi.scheduler.Scheduler() scheduler.add_task(worker='A', task_id='1') scheduler.add_task(worker='B', task_id='2') scheduler.add_task(worker='C', task_id='3') scheduler.add_task(worker='D', task_id='4') self.assertEqual(scheduler.get_work(worker='A')['task_id'], '1') with tempfile.NamedTemporaryFile(delete=True) as fn: def reload_from_disk(scheduler): scheduler._state._state_path = fn.name scheduler.dump() scheduler = luigi.scheduler.Scheduler() scheduler._state._state_path = fn.name scheduler.load() return scheduler scheduler = reload_from_disk(scheduler=scheduler) self.assertEqual(scheduler.get_work(worker='B')['task_id'], '2') self.assertEqual(scheduler.get_work(worker='C')['task_id'], '3') scheduler = reload_from_disk(scheduler=scheduler) self.assertEqual(scheduler.get_work(worker='D')['task_id'], '4')
def test_load_recovers_tasks_index(self): scheduler = luigi.scheduler.Scheduler() scheduler.add_task(worker='A', task_id='1') scheduler.add_task(worker='B', task_id='2') scheduler.add_task(worker='C', task_id='3') scheduler.add_task(worker='D', task_id='4') self.assertEqual(scheduler.get_work(worker='A')['task_id'], '1') with tempfile.NamedTemporaryFile(delete=True) as fn: def reload_from_disk(scheduler): scheduler._state._state_path = fn.name scheduler.dump() scheduler = luigi.scheduler.Scheduler() scheduler._state._state_path = fn.name scheduler.load() return scheduler scheduler = reload_from_disk(scheduler=scheduler) self.assertEqual(scheduler.get_work(worker='B')['task_id'], '2') self.assertEqual(scheduler.get_work(worker='C')['task_id'], '3') scheduler = reload_from_disk(scheduler=scheduler) self.assertEqual(scheduler.get_work(worker='D')['task_id'], '4')