|
9 | 9 | from sdf_xarray import ( |
10 | 10 | SDFPreprocess, |
11 | 11 | _process_latex_name, |
12 | | - _resolve_glob, |
13 | 12 | download, |
| 13 | + resolve_paths, |
14 | 14 | ) |
15 | 15 |
|
16 | 16 | TEST_FILES_DIR = download.fetch_dataset("test_files_1D") |
@@ -205,70 +205,95 @@ def test_multiple_files_multiple_time_dims(): |
205 | 205 | assert df["Absorption_Total_Laser_Energy_Injected"].shape == (11,) |
206 | 206 |
|
207 | 207 |
|
208 | | -def test_resolve_glob_from_string_pattern(): |
| 208 | +def test_resolve_paths_from_string_pattern(): |
209 | 209 | pattern = str(TEST_FILES_DIR / "*.sdf") |
210 | | - result = _resolve_glob(pattern) |
| 210 | + result = resolve_paths(pattern) |
211 | 211 | expected = sorted(TEST_FILES_DIR.glob("*.sdf")) |
212 | 212 | assert result == expected |
213 | 213 |
|
214 | 214 |
|
215 | | -def test_resolve_glob_from_multiple_names_string_pattern(tmp_path): |
| 215 | +def test_resolve_paths_from_multiple_names_string_pattern(tmp_path): |
216 | 216 | mock_test_files_dir = tmp_path |
217 | 217 | (mock_test_files_dir / "normal_0000.sdf").touch() |
218 | 218 | (mock_test_files_dir / "normal_0001.sdf").touch() |
219 | 219 | (mock_test_files_dir / "other_0000.sdf").touch() |
220 | 220 |
|
221 | 221 | pattern = str(mock_test_files_dir / "normal_*.sdf") |
222 | | - result = _resolve_glob(pattern) |
| 222 | + result = resolve_paths(pattern) |
223 | 223 | expected = sorted(mock_test_files_dir.glob("normal_*.sdf")) |
224 | 224 | assert result == expected |
225 | 225 |
|
226 | 226 |
|
227 | | -def test_resolve_glob_from_path_glob(): |
| 227 | +def test_resolve_paths_from_path_glob(): |
228 | 228 | pattern = TEST_FILES_DIR.glob("*.sdf") |
229 | | - result = _resolve_glob(pattern) |
| 229 | + result = resolve_paths(pattern) |
230 | 230 | expected = sorted(TEST_FILES_DIR.glob("*.sdf")) |
231 | 231 | assert result == expected |
232 | 232 |
|
233 | 233 |
|
234 | | -def test_resolve_glob_from_path_missing_glob(): |
| 234 | +def test_resolve_paths_from_directory_path(): |
235 | 235 | pattern = TEST_FILES_DIR |
236 | | - with pytest.raises(TypeError): |
237 | | - _resolve_glob(pattern) |
| 236 | + result = resolve_paths(pattern) |
| 237 | + expected = sorted(TEST_FILES_DIR.glob("*.sdf")) |
| 238 | + assert result == expected |
238 | 239 |
|
239 | 240 |
|
240 | | -def test_resolve_glob_from_path_list(): |
| 241 | +def test_resolve_paths_from_path_list(): |
241 | 242 | pattern = [TEST_FILES_DIR / "0000.sdf"] |
242 | | - result = _resolve_glob(pattern) |
| 243 | + result = resolve_paths(pattern) |
243 | 244 | expected = [TEST_FILES_DIR / "0000.sdf"] |
244 | 245 | assert result == expected |
245 | 246 |
|
246 | 247 |
|
247 | | -def test_resolve_glob_from_path_list_multiple(): |
| 248 | +def test_resolve_paths_from_missing_file(): |
| 249 | + pattern = ["/test/0000.sdf"] |
| 250 | + with pytest.raises(FileNotFoundError): |
| 251 | + resolve_paths(pattern) |
| 252 | + |
| 253 | + |
| 254 | +def test_resolve_paths_from_non_sdf_file(): |
| 255 | + pattern = [TEST_FILES_DIR / "input.deck"] |
| 256 | + with pytest.raises(FileNotFoundError): |
| 257 | + resolve_paths(pattern) |
| 258 | + |
| 259 | + |
| 260 | +def test_resolve_paths_from_path_list_multiple(): |
248 | 261 | pattern = [TEST_FILES_DIR / "0000.sdf", TEST_FILES_DIR / "0001.sdf"] |
249 | | - result = _resolve_glob(pattern) |
| 262 | + result = resolve_paths(pattern) |
250 | 263 | expected = [TEST_FILES_DIR / "0000.sdf", TEST_FILES_DIR / "0001.sdf"] |
251 | 264 | assert result == expected |
252 | 265 |
|
253 | 266 |
|
254 | | -def test_resolve_glob_from_path_list_multiple_unordered(): |
| 267 | +def test_resolve_paths_from_path_list_multiple_unordered(): |
255 | 268 | pattern = [TEST_FILES_DIR / "0001.sdf", TEST_FILES_DIR / "0000.sdf"] |
256 | | - result = _resolve_glob(pattern) |
| 269 | + result = resolve_paths(pattern) |
257 | 270 | expected = [TEST_FILES_DIR / "0000.sdf", TEST_FILES_DIR / "0001.sdf"] |
258 | 271 | assert result == expected |
259 | 272 |
|
260 | 273 |
|
261 | | -def test_resolve_glob_from_path_list_multiple_duplicates(): |
| 274 | +def test_resolve_paths_from_path_list_multiple_duplicates(): |
262 | 275 | pattern = [ |
263 | 276 | TEST_FILES_DIR / "0000.sdf", |
264 | 277 | TEST_FILES_DIR / "0000.sdf", |
265 | 278 | TEST_FILES_DIR / "0001.sdf", |
266 | 279 | ] |
267 | | - result = _resolve_glob(pattern) |
| 280 | + result = resolve_paths(pattern) |
268 | 281 | expected = [TEST_FILES_DIR / "0000.sdf", TEST_FILES_DIR / "0001.sdf"] |
269 | 282 | assert result == expected |
270 | 283 |
|
271 | 284 |
|
| 285 | +def test_resolve_paths_from_path_list_missing_files(): |
| 286 | + pattern = [TEST_FILES_DIR / "0000.sdf", "/test/0000.sdf"] |
| 287 | + with pytest.raises(FileNotFoundError): |
| 288 | + resolve_paths(pattern) |
| 289 | + |
| 290 | + |
| 291 | +def test_resolve_paths_from_path_list_non_sdf_files(): |
| 292 | + pattern = [TEST_FILES_DIR / "0000.sdf", TEST_FILES_DIR / "input.deck"] |
| 293 | + with pytest.raises(FileNotFoundError): |
| 294 | + resolve_paths(pattern) |
| 295 | + |
| 296 | + |
272 | 297 | @pytest.mark.parametrize( |
273 | 298 | ("xrlib", "params"), |
274 | 299 | [ |
|
0 commit comments