-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip_dcm_utils_test.py
More file actions
57 lines (38 loc) · 1.36 KB
/
zip_dcm_utils_test.py
File metadata and controls
57 lines (38 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import logging
import pytest
from zip_dcm_utils import RangePartition, _path_handler
logger = logging.getLogger(__file__)
def test_path_handler_wrong_folder():
with pytest.raises(FileNotFoundError):
paths = _path_handler("./resources/wrongfolder")
assert paths is not None
assert len(paths) == 0
def test_path_handler_zip():
paths = _path_handler("./resources/dcms/y.zip")
assert paths is not None
assert len(paths) == 1
def test_path_handler_folder():
paths = _path_handler("./resources/dcms")
assert paths is not None
assert len(paths) == 5
def test_path_handler_dcm():
paths = _path_handler("./resources/dcms/y/1-1.dcm")
assert len(paths) == 1
def test_readzipdcm_single_zip():
from zip_dcm_utils import _readzipdcm
zip_file_path = "./resources/dcms/y/y.zip"
part = RangePartition(0, 1)
paths = [zip_file_path]
dicom_keys_filter: list[str] = []
res = _readzipdcm(part, paths, dicom_keys_filter)
logger.debug(res)
def test_readzipdcm_single_dcm():
from zip_dcm_utils import _readzipdcm
zip_file_path = "./resources/dcms/y/1-1.dcm"
part = RangePartition(0, 1)
paths = [zip_file_path]
dicom_keys_filter: list[str] = []
res = _readzipdcm(part, paths, dicom_keys_filter)
print(type([_ for _ in res]))
if __name__ == "__main__":
test_readzipdcm_single_dcm()