From fe48906a9f9ce3b38ffbfc7f7418d5d84fec61be Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Tue, 1 Aug 2023 18:27:23 +0100 Subject: [PATCH] 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 https://github.com/galaxyproject/galaxy/pull/16339 --- bioblend/_tests/TestGalaxyLibraries.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bioblend/_tests/TestGalaxyLibraries.py b/bioblend/_tests/TestGalaxyLibraries.py index 4e622b764..eb19cf9f5 100644 --- a/bioblend/_tests/TestGalaxyLibraries.py +++ b/bioblend/_tests/TestGalaxyLibraries.py @@ -1,5 +1,9 @@ import os import tempfile +from typing import ( + Any, + List, +) from . import ( GalaxyTestBase, @@ -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() @@ -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"]