66import pytest
77
88from valor_lite .cache .persistent import (
9- PersistentCache ,
10- PersistentCacheReader ,
11- PersistentCacheWriter ,
9+ FileCache ,
10+ FileCacheReader ,
11+ FileCacheWriter ,
1212)
1313
1414
1515def test_cache_files_empty (tmp_path : Path ):
16- cache = PersistentCache (tmp_path )
16+ cache = FileCache (tmp_path )
1717 assert cache ._path == tmp_path
1818 assert cache .get_files () == []
1919 assert cache .get_dataset_files () == []
@@ -22,7 +22,7 @@ def test_cache_files_empty(tmp_path: Path):
2222
2323def test_cache_files_does_not_exist (tmp_path : Path ):
2424 path = tmp_path / "does_not_exist"
25- cache = PersistentCache (path )
25+ cache = FileCache (path )
2626 assert cache ._path == path
2727 assert cache .get_files () == []
2828 assert cache .get_dataset_files () == []
@@ -39,7 +39,7 @@ def test_cache_reader(tmp_path: Path):
3939 ("some_str" , pa .string ()),
4040 ]
4141 )
42- with PersistentCacheWriter .create (
42+ with FileCacheWriter .create (
4343 path = tmp_path / "cache" ,
4444 schema = schema ,
4545 batch_size = batch_size ,
@@ -57,7 +57,7 @@ def test_cache_reader(tmp_path: Path):
5757 )
5858
5959 writer .write_table (tbl )
60- reader = PersistentCacheReader .load (tmp_path / "cache" )
60+ reader = FileCacheReader .load (tmp_path / "cache" )
6161 assert set (reader .get_files ()) == set (
6262 [
6363 tmp_path / "cache" / "000000.parquet" ,
@@ -99,7 +99,7 @@ def test_cache_reader(tmp_path: Path):
9999def test_cache_reader_does_not_exist (tmp_path : Path ):
100100 path = tmp_path / "does_not_exist"
101101 with pytest .raises (FileNotFoundError ):
102- PersistentCacheReader .load (path )
102+ FileCacheReader .load (path )
103103
104104
105105def test_cache_reader_not_a_directory (tmp_path : Path ):
@@ -108,7 +108,7 @@ def test_cache_reader_not_a_directory(tmp_path: Path):
108108 f .write ("hello world" )
109109
110110 with pytest .raises (NotADirectoryError ):
111- PersistentCacheReader .load (filepath )
111+ FileCacheReader .load (filepath )
112112
113113
114114def test_cache_reader_config_error (tmp_path : Path ):
@@ -122,13 +122,13 @@ def test_cache_reader_config_error(tmp_path: Path):
122122 ]
123123 )
124124 path = tmp_path / "cache"
125- with PersistentCacheWriter .create (
125+ with FileCacheWriter .create (
126126 path = path ,
127127 schema = schema ,
128128 batch_size = batch_size ,
129129 rows_per_file = rows_per_file ,
130130 ) as writer :
131- reader = PersistentCacheReader .load (writer .path )
131+ reader = FileCacheReader .load (writer .path )
132132 assert reader .path == path
133133 assert len (reader .get_files ()) == 1
134134 assert reader .get_files () == [path / ".cfg" ]
@@ -141,13 +141,13 @@ def test_cache_reader_config_error(tmp_path: Path):
141141 json .dump ({}, f , indent = 2 )
142142
143143 with pytest .raises (KeyError ):
144- PersistentCacheReader .load (writer .path )
144+ FileCacheReader .load (writer .path )
145145
146146
147147def test_cache_write_batch (tmp_path : Path ):
148148 batch_size = 10
149149 rows_per_file = 100
150- with PersistentCacheWriter .create (
150+ with FileCacheWriter .create (
151151 path = tmp_path / "cache" ,
152152 schema = pa .schema (
153153 [
@@ -170,7 +170,7 @@ def test_cache_write_batch(tmp_path: Path):
170170 writer .flush ()
171171 assert len (writer .get_files ()) == 11
172172
173- reader = PersistentCacheReader .load (writer .path )
173+ reader = FileCacheReader .load (writer .path )
174174 assert reader .count_rows () == 1000
175175 for idx , tbl in enumerate (reader .iterate_tables ()):
176176 assert tbl ["some_int" ].to_pylist () == [
@@ -190,7 +190,7 @@ def test_cache_write_batch(tmp_path: Path):
190190def test_cache_write_rows (tmp_path : Path ):
191191 batch_size = 10
192192 rows_per_file = 100
193- with PersistentCacheWriter .create (
193+ with FileCacheWriter .create (
194194 path = tmp_path / "cache" ,
195195 schema = pa .schema (
196196 [
@@ -219,7 +219,7 @@ def test_cache_write_rows(tmp_path: Path):
219219 writer .flush ()
220220 assert len (writer .get_files ()) == 11
221221
222- reader = PersistentCacheReader .load (writer .path )
222+ reader = FileCacheReader .load (writer .path )
223223 assert reader .count_rows () == 1000
224224 for idx , tbl in enumerate (reader .iterate_tables ()):
225225 assert tbl ["some_int" ].to_pylist () == [
@@ -239,7 +239,7 @@ def test_cache_write_rows(tmp_path: Path):
239239def test_cache_write_table (tmp_path : Path ):
240240 batch_size = 10
241241 rows_per_file = 100
242- with PersistentCacheWriter .create (
242+ with FileCacheWriter .create (
243243 path = tmp_path / "cache" ,
244244 schema = pa .schema (
245245 [
@@ -267,7 +267,7 @@ def test_cache_write_table(tmp_path: Path):
267267 assert len (writer .get_files ()) == 3
268268 writer .flush ()
269269
270- reader = PersistentCacheReader .load (writer .path )
270+ reader = FileCacheReader .load (writer .path )
271271 assert reader .count_rows () == 202
272272 for tbl in reader .iterate_tables ():
273273 assert tbl ["some_int" ].to_pylist () == [i for i in range (101 )]
@@ -280,7 +280,7 @@ def test_cache_write_table(tmp_path: Path):
280280def test_cache_delete (tmp_path : Path ):
281281 batch_size = 10
282282 rows_per_file = 100
283- with PersistentCacheWriter .create (
283+ with FileCacheWriter .create (
284284 path = tmp_path / "cache" ,
285285 schema = pa .schema (
286286 [
@@ -308,7 +308,7 @@ def test_cache_delete(tmp_path: Path):
308308 assert len (writer .get_files ()) == 3
309309 writer .flush ()
310310
311- reader = PersistentCacheReader .load (path = writer .path )
311+ reader = FileCacheReader .load (path = writer .path )
312312 assert reader .count_rows () == 202
313313 for tbl in reader .iterate_tables ():
314314 assert tbl ["some_int" ].to_pylist () == [i for i in range (101 )]
0 commit comments