def test_including_workflow_path_dispatches_to_include_path(self): workflow = Workflow() with patch.object(workflow, 'include_path', autospec=True) as mock_include_path: workflow.include('/path/to/other_workflow.py') mock_include_path.assert_called_once_with( '/path/to/other_workflow.py', namespace=None)
def test_including_workflow_with_same_name_as_this_workflow_raises_an_exception( self ): workflow = Workflow(name="foo") other_workflow = Workflow(name="foo") with self.assertRaises(WorkflowError): workflow.include(other_workflow)
def test_including_workflow_instance_dispatches_to_include_workflow(self): workflow = Workflow() other_workflow = Workflow() with patch.object(workflow, 'include_workflow', autospec=True) as mock_include_workflow: workflow.include(other_workflow) mock_include_workflow.assert_called_once_with( other_workflow, namespace=None)
def test_including_workflow_path_dispatches_to_include_path(self): workflow = Workflow() with patch.object(workflow, "include_path", autospec=True) as mock_include_path: workflow.include("/path/to/other_workflow.py") mock_include_path.assert_called_once_with( "/path/to/other_workflow.py", namespace=None )
def test_including_workflow_path_dispatches_to_include_path(): workflow = Workflow() with patch.object(workflow, "include_path", autospec=True) as mock_include_path: workflow.include("/path/to/other_workflow.py") mock_include_path.assert_called_once_with("/path/to/other_workflow.py", namespace=None)
def test_raise_error_if_two_targets_in_different_namespaces_produce_the_same_file(self): w1 = Workflow(name='foo') w1.target('SayHello', inputs=[], outputs=['greeting.txt']) w2 = Workflow(name='bar') w2.target('SayHi', inputs=[], outputs=['greeting.txt']) w2.include(w1) with self.assertRaises(FileProvidedByMultipleTargetsError): g = Graph(targets=w2.targets)
def test_including_workflow_instance_dispatches_to_include_workflow(self): workflow = Workflow() other_workflow = Workflow() with patch.object( workflow, "include_workflow", autospec=True ) as mock_include_workflow: workflow.include(other_workflow) mock_include_workflow.assert_called_once_with( other_workflow, namespace=None )
def test_including_workflow_module_gets_workflow_attribute_and_dispatches_to_include_workflow(self, mock_ismodule): workflow = Workflow(working_dir='/some/dir') other_workflow = Workflow(working_dir='/some/other/dir') mock_module = Mock() mock_module.gwf = other_workflow with patch.object(workflow, 'include_workflow', autospec=True) as mock_include_workflow: workflow.include(mock_module) mock_ismodule.assert_called_once_with(mock_module) mock_include_workflow.assert_called_once_with( other_workflow, namespace=None)
def test_dependencies_correctly_resolved_for_named_workflow(self): workflow = Workflow(name='foo') target1 = workflow.target('TestTarget1', inputs=[], outputs=['test.txt']) target2 = workflow.target('TestTarget2', inputs=['test.txt'], outputs=[]) other_workflow = Workflow(name='bar') other_workflow.include(workflow) other_target1 = other_workflow.target('TestTarget1', inputs=['test.txt'], outputs=[]) graph = Graph(targets=other_workflow.targets) assert 'TestTarget1' in graph.targets assert 'foo.TestTarget2' in graph.targets assert 'foo.TestTarget2' in graph.targets
def test_include_target_from_workflow_in_two_different_workflows_(): w1 = Workflow() target = w1.target("MyTarget", inputs=[], outputs=[]) w3 = Workflow() w3.include(w1, namespace="bar") w2 = Workflow() w2.include(w1, namespace="foo") assert target.name == "MyTarget" assert "bar.MyTarget" in w3.targets assert w3.targets["bar.MyTarget"].name == "bar.MyTarget" assert "foo.MyTarget" in w2.targets assert w2.targets["foo.MyTarget"].name == "foo.MyTarget"
def test_include_target_from_workflow_in_two_different_workflows_(self): w1 = Workflow() target = w1.target('MyTarget', inputs=[], outputs=[]) w3 = Workflow() w3.include(w1, namespace='bar') w2 = Workflow() w2.include(w1, namespace='foo') self.assertEqual(target.name, 'MyTarget') self.assertIn('bar.MyTarget', w3.targets) self.assertEqual(w3.targets['bar.MyTarget'].name, 'bar.MyTarget') self.assertIn('foo.MyTarget', w2.targets) self.assertEqual(w2.targets['foo.MyTarget'].name, 'foo.MyTarget')
def test_include_target_from_workflow_in_two_different_workflows_(self): w1 = Workflow() target = w1.target("MyTarget", inputs=[], outputs=[]) w3 = Workflow() w3.include(w1, namespace="bar") w2 = Workflow() w2.include(w1, namespace="foo") self.assertEqual(target.name, "MyTarget") self.assertIn("bar.MyTarget", w3.targets) self.assertEqual(w3.targets["bar.MyTarget"].name, "bar.MyTarget") self.assertIn("foo.MyTarget", w2.targets) self.assertEqual(w2.targets["foo.MyTarget"].name, "foo.MyTarget")
def test_including_workflow_module_gets_workflow_attribute_and_dispatches_to_include_workflow( self, mock_ismodule ): workflow = Workflow(working_dir="/some/dir") other_workflow = Workflow(working_dir="/some/other/dir") mock_module = Mock() mock_module.gwf = other_workflow with patch.object( workflow, "include_workflow", autospec=True ) as mock_include_workflow: workflow.include(mock_module) mock_ismodule.assert_called_once_with(mock_module) mock_include_workflow.assert_called_once_with( other_workflow, namespace=None )
def test_including_non_module_str_and_object_value_raises_type_error(self): workflow = Workflow(working_dir="/some/dir") with self.assertRaises(TypeError): workflow.include(42)
def test_including_non_module_str_and_object_value_raises_type_error(): workflow = Workflow(working_dir="/some/dir") with pytest.raises(TypeError): workflow.include(42)
def test_including_workflow_with_no_name_raises_an_exception(): workflow = Workflow() other_workflow = Workflow() with pytest.raises(WorkflowError): workflow.include(other_workflow)
from gwf import Workflow gwf = Workflow() gwf.include('other_workflow/workflow.py', namespace='other') gwf.target('World', inputs=['other_workflow/a.txt'], outputs=['b.txt']) << """ cat other_workflow/a.txt > b.txt echo world >> b.txt """
def test_including_workflow_with_no_name_raises_an_exception(self): workflow = Workflow() other_workflow = Workflow() with self.assertRaises(WorkflowError): workflow.include(other_workflow)
def test_including_workflow_with_same_name_as_this_workflow_raises_an_exception(self): workflow = Workflow(name='foo') other_workflow = Workflow(name='foo') with self.assertRaises(IncludeWorkflowError): workflow.include(other_workflow)
def test_including_workflow_with_no_name_raises_an_exception(self): workflow = Workflow() other_workflow = Workflow() with self.assertRaises(IncludeWorkflowError): workflow.include(other_workflow)
def test_including_workflow_with_same_name_as_this_workflow_raises_an_exception( ): workflow = Workflow(name="foo") other_workflow = Workflow(name="foo") with pytest.raises(WorkflowError): workflow.include(other_workflow)
def test_including_non_module_str_and_object_value_raises_type_error(self): workflow = Workflow(working_dir='/some/dir') with self.assertRaises(TypeError): workflow.include(42)