Skip to content

Commit

Permalink
Merge pull request #18191 from davelopez/24.1_fix_file_source_query_w…
Browse files Browse the repository at this point in the history
…ith_empty_str

[24.1] Fix file source search query with empty string value
  • Loading branch information
mvdbeek authored May 23, 2024
2 parents a0f67db + 460ce5c commit 2aec162
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/galaxy/files/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/files/sources/_pyfilesystem2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}*"]

Expand Down
12 changes: 12 additions & 0 deletions test/unit/files/test_temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2aec162

Please sign in to comment.