|
1 | 1 | import os |
2 | 2 | import tempfile |
| 3 | +from typing import ( |
| 4 | + Any, |
| 5 | + List, |
| 6 | +) |
3 | 7 |
|
4 | 8 | from . import ( |
5 | 9 | GalaxyTestBase, |
|
9 | 13 | FOO_DATA = "foo\nbar\n" |
10 | 14 |
|
11 | 15 |
|
| 16 | +def listify(item: Any) -> List: |
| 17 | + # Slightly simplified version of listify() from |
| 18 | + # https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/util/__init__.py |
| 19 | + if not item: |
| 20 | + return [] |
| 21 | + elif isinstance(item, (list, tuple)): |
| 22 | + return list(item) |
| 23 | + elif isinstance(item, str) and item.count(","): |
| 24 | + return [token.strip() for token in item.split(",")] |
| 25 | + return [item] |
| 26 | + |
| 27 | + |
12 | 28 | class TestGalaxyLibraries(GalaxyTestBase.GalaxyTestBase): |
13 | 29 | def setUp(self): |
14 | 30 | super().setUp() |
@@ -151,15 +167,15 @@ def test_dataset_permissions(self): |
151 | 167 | def test_upload_file_contents_with_tags(self): |
152 | 168 | datasets = self.gi.libraries.upload_file_contents(self.library["id"], FOO_DATA, tags=["name:foobar", "barfoo"]) |
153 | 169 | dataset_show = self.gi.libraries.show_dataset(self.library["id"], datasets[0]["id"]) |
154 | | - assert dataset_show["tags"] == "name:foobar, barfoo" |
| 170 | + assert listify(dataset_show["tags"]) == ["name:foobar", "barfoo"] |
155 | 171 |
|
156 | 172 | @test_util.skip_unless_galaxy("release_19.09") |
157 | 173 | def test_update_dataset_tags(self): |
158 | 174 | datasets = self.gi.libraries.upload_file_contents(self.library["id"], FOO_DATA) |
159 | 175 | dataset_show = self.gi.libraries.show_dataset(self.library["id"], datasets[0]["id"]) |
160 | | - assert dataset_show["tags"] == "" |
| 176 | + assert listify(dataset_show["tags"]) == [] |
161 | 177 |
|
162 | 178 | updated_dataset = self.gi.libraries.update_library_dataset(datasets[0]["id"], tags=["name:foobar", "barfoo"]) |
163 | 179 | dataset_show = self.gi.libraries.show_dataset(self.library["id"], updated_dataset["id"]) |
164 | 180 |
|
165 | | - assert dataset_show["tags"] == "name:foobar, barfoo" |
| 181 | + assert listify(dataset_show["tags"]) == ["name:foobar", "barfoo"] |
0 commit comments