Пример #1
0
 def test_get_prefix_direct(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.direct_workflow_version)
     prefix = loader.get_prefix()
     # Does not use tmpdir
     self.assertEqual(prefix, 'file:///direct/')
     self.assertFalse(mock_mkdtemp.called)
Пример #2
0
 def test__download_workflow(self, mock_urlretrieve, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.zipped_workflow_version)
     loader._download_workflow()
     self.assertEqual(
         mock_urlretrieve.call_args,
         call(self.zipped_workflow_version.url, loader.download_path))
Пример #3
0
 def test__handle_download_zipped(self, mock_zipfile, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.zipped_workflow_version)
     loader._handle_download()
     self.assertTrue(mock_zipfile.called)
     self.assertEqual(
         mock_zipfile.return_value.__enter__.return_value.extractall.
         call_args, call(loader.download_dir))
Пример #4
0
 def test__get_tool_path_raises(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     self.workflow_version.workflow_type = 'other'
     loader = BespinWorkflowLoader(self.workflow_version)
     with self.assertRaises(InvalidWorkflowFileException) as context:
         tool_path = loader._get_tool_path()
     self.assertIn('Workflow type other is not supported',
                   str(context.exception))
Пример #5
0
 def test__load_downloaded_workflow(self, mock_context, mock_get_tool_path,
                                    mock_load_tool, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     mock_get_tool_path.return_value = 'tool-path'
     loader = BespinWorkflowLoader(self.workflow_version)
     loaded = loader._load_downloaded_workflow()
     self.assertEqual(loaded, mock_load_tool.return_value)
     self.assertEqual(mock_load_tool.call_args,
                      call('tool-path', mock_context.return_value))
Пример #6
0
 def __init__(self, workflow_version):
     loader = BespinWorkflowLoader(workflow_version)
     parser = BespinWorkflowParser(loader.load())
     prefix = loader.get_prefix()
     builder = ToolDetailsBuilder(prefix)
     builder.accept(parser.loaded_workflow)
     self.version = parser.version
     self.tag = parser.tag
     self.contents = builder.build()
Пример #7
0
 def test_init_direct(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.direct_workflow_version)
     self.assertFalse(mock_mkdtemp.called)
     self.assertEqual(loader.workflow_version, self.direct_workflow_version)
     self.assertFalse(hasattr(loader, 'download_path'))
     self.assertFalse(hasattr(loader, 'download_dir'))
Пример #8
0
 def test_load(self, mock_cleanup, mock_load_downloaded_workflow,
               mock_handle_download, mock_download_workflow, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.workflow_version)
     manager = Mock()
     manager.attach_mock(mock_download_workflow, 'download')
     manager.attach_mock(mock_handle_download, 'handle')
     manager.attach_mock(mock_load_downloaded_workflow, 'load_downloaded')
     manager.attach_mock(mock_cleanup, 'cleanup')
     loaded = loader.load()
     self.assertEqual(manager.mock_calls, [
         call.download(),
         call.handle(),
         call.load_downloaded(),
         call.cleanup()
     ])
     # Make sure we assert this check after the order, because it interferes with the calls
     self.assertEqual(loaded, mock_load_downloaded_workflow.return_value)
Пример #9
0
 def test_init_common(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.workflow_version)
     self.assertEqual(loader.download_dir, mock_mkdtemp.return_value)
     self.assertEqual(loader.workflow_version, self.workflow_version)
     self.assertEqual(loader.download_path, '/tmpdir/workflow.cwl')
Пример #10
0
 def test_get_prefix_zipped(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.zipped_workflow_version)
     prefix = loader.get_prefix()
     self.assertEqual(prefix, 'file:///tmpdir/unzipped/')
Пример #11
0
 def test__cleanup_direct(self, mock_rmtree, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.direct_workflow_version)
     loader._cleanup()
     self.assertFalse(mock_rmtree.called)
Пример #12
0
 def test__get_tool_path_direct(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.direct_workflow_version)
     tool_path = loader._get_tool_path()
     self.assertEqual(tool_path, 'file:///direct/direct.cwl')
Пример #13
0
 def test__get_tool_path_zipped(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.zipped_workflow_version)
     tool_path = loader._get_tool_path()
     self.assertEqual(tool_path, '/tmpdir/unzipped/workflow.cwl')
Пример #14
0
 def test__get_tool_path_packed(self, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.packed_workflow_version)
     tool_path = loader._get_tool_path()
     self.assertEqual(tool_path, '/tmpdir/packed.cwl#main')
Пример #15
0
 def test__handle_download_packed(self, mock_zipfile, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.packed_workflow_version)
     loader._handle_download()
     self.assertFalse(mock_zipfile.called)
Пример #16
0
 def test__no_download_direct(self, mock_urlretriefve, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.direct_workflow_version)
     loader._download_workflow()
     self.assertFalse(mock_mkdtemp.called)
     self.assertFalse(mock_urlretriefve.called)
Пример #17
0
 def test__cleanup_zipped(self, mock_rmtree, mock_mkdtemp):
     self.setup_mkdtemp(mock_mkdtemp)
     loader = BespinWorkflowLoader(self.zipped_workflow_version)
     loader._cleanup()
     self.assertEqual(mock_rmtree.call_args, call(loader.download_dir))