Skip to content

Commit 0456bd3

Browse files
committed
more tests
1 parent b27591c commit 0456bd3

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/valor_lite/common/persistent.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_dataset_files(self) -> list[Path]:
112112

113113
class FileCacheReader(FileCache):
114114
@classmethod
115-
def load(cls, path: str | Path | FileCache):
115+
def load(cls, path: str | Path):
116116
"""
117117
Load cache from disk.
118118
@@ -121,8 +121,6 @@ def load(cls, path: str | Path | FileCache):
121121
path : str | Path
122122
Where the cache is stored.
123123
"""
124-
if isinstance(path, FileCache):
125-
path = path.path
126124
path = Path(path)
127125
if not path.exists():
128126
raise FileNotFoundError(f"Directory does not exist: {path}")

tests/common/test_persistent_cache.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,33 @@ def test_cache_delete(tmp_path: Path):
298298
batch_size = 10
299299
rows_per_file = 100
300300
path = tmp_path / "cache"
301+
302+
FileCacheWriter.create(
303+
path=path,
304+
schema=pa.schema(
305+
[
306+
("some_int", pa.int64()),
307+
("some_float", pa.float64()),
308+
("some_str", pa.string()),
309+
]
310+
),
311+
batch_size=batch_size,
312+
rows_per_file=rows_per_file,
313+
)
314+
with pytest.raises(FileExistsError):
315+
FileCacheWriter.create(
316+
path=path,
317+
schema=pa.schema(
318+
[
319+
("some_int", pa.int64()),
320+
("some_float", pa.float64()),
321+
("some_str", pa.string()),
322+
]
323+
),
324+
batch_size=batch_size,
325+
rows_per_file=rows_per_file,
326+
)
327+
301328
with FileCacheWriter.create(
302329
path=path,
303330
schema=pa.schema(
@@ -309,6 +336,7 @@ def test_cache_delete(tmp_path: Path):
309336
),
310337
batch_size=batch_size,
311338
rows_per_file=rows_per_file,
339+
delete_if_exists=True,
312340
) as writer:
313341
tbl = pa.Table.from_pylist(
314342
[

0 commit comments

Comments
 (0)