예제 #1
0
 def _restore_graph(self, operations):
     mock_wf_ctx = mock.Mock()
     mock_wf_ctx.get_operations.return_value = [
         Operation(op) for op in operations
     ]
     mock_retrieved_graph = mock.Mock(id=0)
     return TaskDependencyGraph.restore(mock_wf_ctx, mock_retrieved_graph)
예제 #2
0
+            'dependencies': [],
+            'parameters': {
+                'info': {},
+                'current_retries': 0,
+                'send_task_events': False,
+                'containing_subgraph': None,
+                'task_kwargs': {}
+            }
+        }
+
+    def _restore_graph(self, operations):
+        mock_wf_ctx = mock.Mock()
+        mock_wf_ctx.get_operations.return_value = [
+            Operation(op) for op in operations]
+        mock_retrieved_graph = mock.Mock(id=0)
+        return TaskDependencyGraph.restore(mock_wf_ctx, mock_retrieved_graph)
+
+    def test_restore_empty(self):
+        """Restoring an empty list of operations results in an empty graph"""
+        graph = self._restore_graph([])
+        operations = list(graph.tasks_iter())
+        assert operations == []
+
+    def test_restore_single(self):
+        """A single operation is restored into the graph"""
+        graph = self._restore_graph([self._remote_task()])
+        operations = list(graph.tasks_iter())
+        assert len(operations) == 1
+        assert isinstance(operations[0], tasks.RemoteWorkflowTask)
+
+    def test_restore_finished(self):