|
| 1 | +from pathlib import Path |
1 | 2 | from typing import List, Optional |
2 | 3 | from unittest.mock import MagicMock, patch |
3 | 4 |
|
|
21 | 22 | TrinoRetrievalJob, |
22 | 23 | ) |
23 | 24 | from feast.infra.offline_stores.dask import DaskRetrievalJob |
| 25 | +from feast.infra.offline_stores.file_source import FileSource |
24 | 26 | from feast.infra.offline_stores.offline_store import RetrievalJob, RetrievalMetadata |
25 | 27 | from feast.infra.offline_stores.redshift import ( |
26 | 28 | RedshiftOfflineStoreConfig, |
@@ -246,3 +248,26 @@ def test_to_arrow_timeout(retrieval_job, timeout: Optional[int]): |
246 | 248 | with patch.object(retrieval_job, "_to_arrow_internal") as mock_to_arrow_internal: |
247 | 249 | retrieval_job.to_arrow(timeout=timeout) |
248 | 250 | mock_to_arrow_internal.assert_called_once_with(timeout=timeout) |
| 251 | + |
| 252 | + |
| 253 | +@pytest.mark.parametrize( |
| 254 | + "repo_path, uri, expected", |
| 255 | + [ |
| 256 | + # Remote URI - Should return as-is |
| 257 | + ( |
| 258 | + Path("/some/repo"), |
| 259 | + "s3://bucket-name/file.parquet", |
| 260 | + "s3://bucket-name/file.parquet", |
| 261 | + ), |
| 262 | + # Absolute Path - Should return as-is |
| 263 | + (Path("/some/repo"), "/abs/path/file.parquet", "/abs/path/file.parquet"), |
| 264 | + # Relative Path with repo_path - Should combine |
| 265 | + (Path("/some/repo"), "data/output.parquet", "/some/repo/data/output.parquet"), |
| 266 | + # Relative Path without repo_path - Should return absolute path |
| 267 | + (None, "C:/path/to/file.parquet", "C:/path/to/file.parquet"), |
| 268 | + ], |
| 269 | + ids=["s3_uri", "absolute_path", "relative_path", "windows_path"], |
| 270 | +) |
| 271 | +def test_get_uri_for_file_path(repo_path, uri, expected): |
| 272 | + result = FileSource.get_uri_for_file_path(repo_path=repo_path, uri=uri) |
| 273 | + assert result == expected, f"Expected {expected}, but got {result}" |
0 commit comments