Skip to content

Commit

Permalink
Update tests for libraries API change in Galaxy 23.1
Browse files Browse the repository at this point in the history
Now library dataset tags are serialized as lists of strings instead
of a comma-separated string, see
galaxyproject/galaxy#16339
  • Loading branch information
nsoranzo committed Aug 1, 2023
1 parent e5f3ef2 commit fe48906
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions bioblend/_tests/TestGalaxyLibraries.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os
import tempfile
from typing import (
Any,
List,
)

from . import (
GalaxyTestBase,
Expand All @@ -9,6 +13,18 @@
FOO_DATA = "foo\nbar\n"


def listify(item: Any) -> List:
# Slightly simplified version of listify() from
# https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/util/__init__.py
if not item:
return []
elif isinstance(item, (list, tuple)):
return list(item)
elif isinstance(item, str) and item.count(","):
return [token.strip() for token in item.split(",")]
return [item]


class TestGalaxyLibraries(GalaxyTestBase.GalaxyTestBase):
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -151,15 +167,15 @@ def test_dataset_permissions(self):
def test_upload_file_contents_with_tags(self):
datasets = self.gi.libraries.upload_file_contents(self.library["id"], FOO_DATA, tags=["name:foobar", "barfoo"])
dataset_show = self.gi.libraries.show_dataset(self.library["id"], datasets[0]["id"])
assert dataset_show["tags"] == "name:foobar, barfoo"
assert listify(dataset_show["tags"]) == ["name:foobar", "barfoo"]

@test_util.skip_unless_galaxy("release_19.09")
def test_update_dataset_tags(self):
datasets = self.gi.libraries.upload_file_contents(self.library["id"], FOO_DATA)
dataset_show = self.gi.libraries.show_dataset(self.library["id"], datasets[0]["id"])
assert dataset_show["tags"] == ""
assert listify(dataset_show["tags"]) == []

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

assert dataset_show["tags"] == "name:foobar, barfoo"
assert listify(dataset_show["tags"]) == ["name:foobar", "barfoo"]

0 comments on commit fe48906

Please sign in to comment.