From 9cfc7e2c3ae66ffb52ea89c32aedf83c720fc3ab Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 21 May 2024 15:16:23 +0200 Subject: [PATCH 1/3] Add unit test to check empty query string --- test/unit/files/test_temp.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/unit/files/test_temp.py b/test/unit/files/test_temp.py index 98f188fb7014..2d51a359916b 100644 --- a/test/unit/files/test_temp.py +++ b/test/unit/files/test_temp.py @@ -131,6 +131,18 @@ def test_search(temp_file_source: TempFilesSource): assert result[0]["name"] == "e" +def test_query_with_empty_string(temp_file_source: TempFilesSource): + recursive = False + root_lvl_entries, count = temp_file_source.list("/", recursive=recursive) + assert count == 4 + assert len(root_lvl_entries) == 4 + + result, count = temp_file_source.list("/", recursive=recursive, query="") + assert count == 4 + assert len(result) == 4 + assert result == root_lvl_entries + + def test_pagination_not_supported_raises(temp_file_source: TempFilesSource): TempFilesSource.supports_pagination = False recursive = False From 063fdf8c11a15c64697bef7d8d9e080b397caa32 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 21 May 2024 15:19:01 +0200 Subject: [PATCH 2/3] Fix wrong search query when empty string Providing query="" (empty) string will construct "**" as query which is incorrect, it should return None instead. --- lib/galaxy/files/sources/_pyfilesystem2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/files/sources/_pyfilesystem2.py b/lib/galaxy/files/sources/_pyfilesystem2.py index fd3fccb8ba56..5fa7917f3ac2 100644 --- a/lib/galaxy/files/sources/_pyfilesystem2.py +++ b/lib/galaxy/files/sources/_pyfilesystem2.py @@ -111,7 +111,7 @@ def _to_page(self, limit: Optional[int] = None, offset: Optional[int] = None) -> return (start, end) def _query_to_filter(self, query: Optional[str]) -> Optional[List[str]]: - if query is None: + if not query: return None return [f"*{query}*"] From 460ce5c56ba283a31c2123bec2d9e282d4c22af7 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 21 May 2024 17:20:08 +0200 Subject: [PATCH 3/3] Strip `supports` when parsing common config options To avoid passing unknown keyword parameters to file sources. --- lib/galaxy/files/sources/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/galaxy/files/sources/__init__.py b/lib/galaxy/files/sources/__init__.py index 6d980c5a1286..19fcc1b21475 100644 --- a/lib/galaxy/files/sources/__init__.py +++ b/lib/galaxy/files/sources/__init__.py @@ -393,6 +393,7 @@ def _parse_common_config_opts(self, kwd: FilesSourceProperties): kwd.pop("uri_root", None) kwd.pop("type", None) kwd.pop("browsable", None) + kwd.pop("supports", None) return kwd def to_dict(self, for_serialization=False, user_context: "OptionalUserContext" = None) -> FilesSourceProperties: