comparison env/lib/python3.7/site-packages/bioblend/_tests/TestGalaxyDatasets.py @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
comparison
equal deleted inserted replaced
1:75ca89e9b81c 2:6af9afd405e9
1 import shutil
2 import tempfile
3
4 import six
5
6 from . import (
7 GalaxyTestBase,
8 test_util
9 )
10
11
12 class TestGalaxyDatasets(GalaxyTestBase.GalaxyTestBase):
13
14 def setUp(self):
15 super(TestGalaxyDatasets, self).setUp()
16 self.history_id = self.gi.histories.create_history(name='TestShowDataset')['id']
17 self.dataset_contents = "line 1\nline 2\rline 3\r\nline 4"
18 self.dataset_id = self._test_dataset(self.history_id, contents=self.dataset_contents)
19
20 def tearDown(self):
21 self.gi.histories.delete_history(self.history_id, purge=True)
22
23 @test_util.skip_unless_galaxy('release_19.05')
24 def test_show_nonexistent_dataset(self):
25 with self.assertRaises(Exception):
26 self.gi.datasets.show_dataset('nonexistent_id')
27
28 def test_show_dataset(self):
29 self.gi.datasets.show_dataset(self.dataset_id)
30
31 def test_download_dataset(self):
32 with self.assertRaises(Exception):
33 self.gi.datasets.download_dataset(None)
34 expected_contents = six.b("\n".join(self.dataset_contents.splitlines()) + "\n")
35 # download_dataset() with file_path=None is already tested in TestGalaxyTools.test_paste_content()
36 # self._wait_and_verify_dataset(self.dataset_id, expected_contents)
37 tempdir = tempfile.mkdtemp(prefix='bioblend_test_')
38 try:
39 downloaded_dataset = self.gi.datasets.download_dataset(
40 self.dataset_id, file_path=tempdir,
41 maxwait=GalaxyTestBase.BIOBLEND_TEST_JOB_TIMEOUT)
42 self.assertTrue(downloaded_dataset.startswith(tempdir))
43 with open(downloaded_dataset, 'rb') as f:
44 self.assertEqual(f.read(), expected_contents)
45 finally:
46 shutil.rmtree(tempdir)
47 with tempfile.NamedTemporaryFile(prefix='bioblend_test_') as f:
48 download_filename = self.gi.datasets.download_dataset(
49 self.dataset_id, file_path=f.name, use_default_filename=False,
50 maxwait=GalaxyTestBase.BIOBLEND_TEST_JOB_TIMEOUT)
51 self.assertEqual(download_filename, f.name)
52 f.flush()
53 self.assertEqual(f.read(), expected_contents)
54
55 def test_show_stderr(self):
56 stderr = self.gi.datasets.show_stderr(self.dataset_id)
57 self.assertIsNotNone(stderr)
58
59 def test_show_stdout(self):
60 stdout = self.gi.datasets.show_stdout(self.dataset_id)
61 self.assertIsNotNone(stdout)