diff --git a/pysus/api/client.py b/pysus/api/client.py index bb54f2aa..3fa80c19 100644 --- a/pysus/api/client.py +++ b/pysus/api/client.py @@ -761,7 +761,11 @@ async def query( if client: prefix = f"public/data/{client.lower()}/" - files = [f for f in files if str(f.path).startswith(prefix)] + files = [ + f + for f in files + if str(f.path).replace("\\", "/").startswith(prefix) + ] if not as_dataframe: return files diff --git a/pysus/tests/api/test_client.py b/pysus/tests/api/test_client.py index 78a24122..b36b9d0f 100644 --- a/pysus/tests/api/test_client.py +++ b/pysus/tests/api/test_client.py @@ -513,6 +513,7 @@ async def test_query_no_dataset_iterates_all(self, test_db_path): @pytest.mark.asyncio async def test_query_with_client_filter(self, test_db_path): + from pathlib import PureWindowsPath from unittest.mock import AsyncMock, MagicMock from pysus.api.ducklake.client import DuckLake @@ -529,7 +530,12 @@ async def test_query_with_client_filter(self, test_db_path): mock_file2 = MagicMock() mock_file2.path = "public/data/dadosgov/otherfile" - ds.query = AsyncMock(return_value=[mock_file1, mock_file2]) + # DuckLake may return WindowsPath instances on Windows. The client + # filter must compare normalized POSIX paths so FTP files are retained. + mock_file3 = MagicMock() + mock_file3.path = PureWindowsPath("public/data/ftp/windows-file") + + ds.query = AsyncMock(return_value=[mock_file1, mock_file2, mock_file3]) mock_ducklake.datasets = AsyncMock(return_value=[ds]) client._ducklake = mock_ducklake @@ -537,7 +543,7 @@ async def test_query_with_client_filter(self, test_db_path): result = await client.query(dataset="sinan", client=FTP) - assert result == [mock_file1] + assert result == [mock_file1, mock_file3] await client.__aexit__(None, None, None)