|
33 | 33 | from servicex.configuration import Configuration |
34 | 34 | from servicex.models import ResultFormat |
35 | 35 | from servicex.query_cache import QueryCache, CacheException |
36 | | -from tinydb import Query |
37 | 36 |
|
38 | 37 | file_uris = ["/tmp/foo1.root", "/tmp/foo2.root"] |
39 | 38 |
|
@@ -185,83 +184,7 @@ def test_record_delete(transform_request, completed_status): |
185 | 184 | cache.close() |
186 | 185 |
|
187 | 186 |
|
188 | | -def test_get_codegen_by_backend_empty(): |
189 | | - with tempfile.TemporaryDirectory() as temp_dir: |
190 | | - config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
191 | | - cache = QueryCache(config) |
192 | | - result = cache.get_codegen_by_backend("non-existent") |
193 | | - assert result is None |
194 | | - cache.close() |
195 | | - |
196 | | - |
197 | | -def test_update_codegen_by_backend_single(): |
198 | | - with tempfile.TemporaryDirectory() as temp_dir: |
199 | | - config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
200 | | - cache = QueryCache(config) |
201 | | - codegens = Query() |
202 | | - cache.update_codegen_by_backend("backend_1", ["codegen_1"]) |
203 | | - result = cache.db.search(codegens.backend == "backend_1") |
204 | | - assert len(result) == 1 |
205 | | - assert result[0] == {"backend": "backend_1", "codegens": ["codegen_1"]} |
206 | | - cache.close() |
207 | | - |
208 | | - |
209 | | -def test_get_codegen_by_backend_single(): |
210 | | - with tempfile.TemporaryDirectory() as temp_dir: |
211 | | - config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
212 | | - cache = QueryCache(config) |
213 | | - cache.update_codegen_by_backend("backend_1", ["codegen_1"]) |
214 | | - result = cache.get_codegen_by_backend("backend_1") |
215 | | - assert result == {"backend": "backend_1", "codegens": ["codegen_1"]} |
216 | | - cache.close() |
217 | | - |
218 | | - |
219 | | -def test_delete_codegen_by_backend(): |
220 | | - with tempfile.TemporaryDirectory() as temp_dir: |
221 | | - config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
222 | | - cache = QueryCache(config) |
223 | | - cache.update_codegen_by_backend("backend_1", ["codegen_1"]) |
224 | | - result = cache.get_codegen_by_backend("backend_1") |
225 | | - assert result == {"backend": "backend_1", "codegens": ["codegen_1"]} |
226 | | - |
227 | | - cache.delete_codegen_by_backend("backend_1") |
228 | | - result = cache.get_codegen_by_backend("backend_1") |
229 | | - assert result is None |
230 | | - cache.close() |
231 | | - |
232 | | - |
233 | | -def test_delete_codegen_by_backend_nonexistent(): |
234 | | - with tempfile.TemporaryDirectory() as temp_dir: |
235 | | - config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
236 | | - cache = QueryCache(config) |
237 | | - cache.delete_codegen_by_backend("backend_1") |
238 | | - with pytest.raises(AssertionError): |
239 | | - raise AssertionError() |
240 | | - cache.close() |
241 | | - |
242 | | - |
243 | | -def test_add_both_codegen_and_transform_to_cache(transform_request, completed_status): |
244 | | - with tempfile.TemporaryDirectory() as temp_dir: |
245 | | - config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
246 | | - cache = QueryCache(config) |
247 | | - cache.cache_transform( |
248 | | - cache.transformed_results( |
249 | | - transform=transform_request, |
250 | | - completed_status=completed_status, |
251 | | - data_dir="/foo/bar", |
252 | | - file_list=file_uris, |
253 | | - signed_urls=[], |
254 | | - ) |
255 | | - ) |
256 | | - |
257 | | - cache.update_codegen_by_backend("backend_1", ["codegen_1"]) |
258 | | - result = cache.get_codegen_by_backend("backend_1") |
259 | | - assert result == {"backend": "backend_1", "codegens": ["codegen_1"]} |
260 | | - assert len(cache.cached_queries()) == 1 |
261 | | - cache.close() |
262 | | - |
263 | | - |
264 | | -def test_delete_codegen_by_hash(transform_request, completed_status): |
| 187 | +def test_delete_transform_by_hash(transform_request, completed_status): |
265 | 188 | with tempfile.TemporaryDirectory() as temp_dir: |
266 | 189 | config = Configuration(cache_path=temp_dir, api_endpoints=[]) # type: ignore |
267 | 190 | cache = QueryCache(config) |
|
0 commit comments