Skip to content

Commit fe48906

Browse files
committed
Update tests for libraries API change in Galaxy 23.1
Now library dataset tags are serialized as lists of strings instead of a comma-separated string, see galaxyproject/galaxy#16339
1 parent e5f3ef2 commit fe48906

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

bioblend/_tests/TestGalaxyLibraries.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import os
22
import tempfile
3+
from typing import (
4+
Any,
5+
List,
6+
)
37

48
from . import (
59
GalaxyTestBase,
@@ -9,6 +13,18 @@
913
FOO_DATA = "foo\nbar\n"
1014

1115

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+
1228
class TestGalaxyLibraries(GalaxyTestBase.GalaxyTestBase):
1329
def setUp(self):
1430
super().setUp()
@@ -151,15 +167,15 @@ def test_dataset_permissions(self):
151167
def test_upload_file_contents_with_tags(self):
152168
datasets = self.gi.libraries.upload_file_contents(self.library["id"], FOO_DATA, tags=["name:foobar", "barfoo"])
153169
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"]
155171

156172
@test_util.skip_unless_galaxy("release_19.09")
157173
def test_update_dataset_tags(self):
158174
datasets = self.gi.libraries.upload_file_contents(self.library["id"], FOO_DATA)
159175
dataset_show = self.gi.libraries.show_dataset(self.library["id"], datasets[0]["id"])
160-
assert dataset_show["tags"] == ""
176+
assert listify(dataset_show["tags"]) == []
161177

162178
updated_dataset = self.gi.libraries.update_library_dataset(datasets[0]["id"], tags=["name:foobar", "barfoo"])
163179
dataset_show = self.gi.libraries.show_dataset(self.library["id"], updated_dataset["id"])
164180

165-
assert dataset_show["tags"] == "name:foobar, barfoo"
181+
assert listify(dataset_show["tags"]) == ["name:foobar", "barfoo"]

0 commit comments

Comments
 (0)