def test_get_flow_state(self): lb, fd = p_utils.temporary_flow_detail(backend=self.backend) fd.state = states.INTERRUPTED with contextlib.closing(self.backend.get_connection()) as conn: fd.update(conn.update_flow_details(fd)) s = storage.Storage(flow_detail=fd, backend=self.backend) self.assertEquals(s.get_flow_state(), states.INTERRUPTED)
def test_sequential_flow_two_tasks_with_resumption(self): flow = lf.Flow('lf-2-r').add( TestTask(self.values, name='task1', provides='x1'), TestTask(self.values, name='task2', provides='x2') ) # Create FlowDetail as if we already run task1 _lb, fd = p_utils.temporary_flow_detail(self.backend) td = logbook.TaskDetail(name='task1', uuid='42') td.state = states.SUCCESS td.results = 17 fd.add(td) with contextlib.closing(self.backend.get_connection()) as conn: fd.update(conn.update_flow_details(fd)) td.update(conn.update_task_details(td)) engine = self._make_engine(flow, fd) engine.run() self.assertEquals(self.values, ['task2']) self.assertEquals(engine.storage.fetch_all(), {'x1': 17, 'x2': 5})
def test_non_saving_storage(self): _lb, flow_detail = p_utils.temporary_flow_detail(self.backend) s = storage.Storage(flow_detail=flow_detail) # no backend s.add_task('42', 'my task') self.assertEquals(s.get_uuid_by_name('my task'), '42')
def _get_storage(self): lb, flow_detail = p_utils.temporary_flow_detail(self.backend) return storage.Storage(backend=self.backend, flow_detail=flow_detail)