Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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
            )
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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
            )
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
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"
Exemplo n.º 11
0
    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')
Exemplo n.º 12
0
    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")
Exemplo n.º 13
0
    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
            )
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
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)
Exemplo n.º 16
0
def test_including_workflow_with_no_name_raises_an_exception():
    workflow = Workflow()
    other_workflow = Workflow()
    with pytest.raises(WorkflowError):
        workflow.include(other_workflow)
Exemplo n.º 17
0
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
"""

Exemplo n.º 18
0
 def test_including_workflow_with_no_name_raises_an_exception(self):
     workflow = Workflow()
     other_workflow = Workflow()
     with self.assertRaises(WorkflowError):
         workflow.include(other_workflow)
Exemplo n.º 19
0
 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)
Exemplo n.º 20
0
 def test_including_workflow_with_no_name_raises_an_exception(self):
     workflow = Workflow()
     other_workflow = Workflow()
     with self.assertRaises(IncludeWorkflowError):
         workflow.include(other_workflow)
Exemplo n.º 21
0
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)
Exemplo n.º 22
0
 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)