Source code for ewoksid16b.tests.test_filtering

import os

from ewoksid16b.for_scripts.filtering import filter_files

from .data import resource_path


[docs] def test_filter_files_real_data_specific_sample_dataset(): with resource_path("RAW_DATA") as path: result = filter_files(str(path), "test_blissname", "0001", "hama1_det00", None) assert len(result) == 1 file_path, groups, scans = result[0] assert "test_blissname_0001.h5" in file_path assert groups == ["1.1", "2.1"] assert scans == [1, 2]
[docs] def test_filter_files_real_data_wildcard_sample(): with resource_path("RAW_DATA") as path: result = filter_files(str(path), "test_*", None, "hama1_det00", None) assert len(result) == 1 for file_path, groups, scans in result: # Extract sample name from path parts = file_path.split(os.sep) sample_dir = None for part in reversed(parts): if part.startswith("test_"): sample_dir = part break assert sample_dir is not None assert sample_dir.startswith("test_")
[docs] def test_filter_files_real_data_scan_filter(): with resource_path("RAW_DATA") as path: result = filter_files(str(path), None, None, "hama1_det00", [1]) assert len(result) == 5 for file_path, groups, scans in result: assert all(scan in [1] for scan in scans) assert all(group == f"{scan}.1" for scan, group in zip(scans, groups))
[docs] def test_filter_files_real_data_multiple_scans(): with resource_path("RAW_DATA") as path: result = filter_files(str(path), None, None, "hama1_det00", [1, 2]) assert len(result) == 7 # Based on validation for file_path, groups, scans in result: # Should have at least one of the requested scans assert any(scan in [1, 2] for scan in scans)
# non-existent scan
[docs] def test_filter_files_real_data_nonexistent_scan(): with resource_path("RAW_DATA") as path: result = filter_files(str(path), None, None, "hama1_det00", [999]) assert result == []
# non-existent detector
[docs] def test_filter_files_real_data_nonexistent_detector(): with resource_path("RAW_DATA") as path: result = filter_files(str(path), None, None, "nonexistent_det", None) assert result == []