-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(tests): add regression test for path handling
- Loading branch information
1 parent
a4665f6
commit 4755733
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../bin/make_studyvisit_archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
import sys | ||
import tarfile | ||
from pathlib import Path | ||
|
||
from .modules.make_studyvisit_archive import main | ||
|
||
|
||
def test_path_hanling(tmp_path): | ||
base_dir = tmp_path / 'input' / 'd_1' / 'd_1_1' / 'd_1_1_1' | ||
base_dir.mkdir(parents=True) | ||
(base_dir / 'file1.txt').write_text('content 1') | ||
(base_dir / 'file2.txt').write_text('content 2') | ||
|
||
output_base_dir = tmp_path / 'output' | ||
|
||
study_id, visit_id = 'study_1', 'visit_1' | ||
main(str(base_dir), str(output_base_dir), study_id, visit_id) | ||
|
||
tar_file = tarfile.open(output_base_dir / study_id / f'{visit_id}_dicom.tar') | ||
assert tar_file.getnames() == [ | ||
f'{study_id}_{visit_id}/file1.txt', | ||
f'{study_id}_{visit_id}/file2.txt', | ||
] |