Skip to content

Commit

Permalink
enh(tests): add regression test for path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-monch committed Jul 5, 2024
1 parent a4665f6 commit 4755733
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Empty file added tests/modules/__init__.py
Empty file.
1 change: 1 addition & 0 deletions tests/modules/make_studyvisit_archive.py
24 changes: 24 additions & 0 deletions tests/test_path_handling.py
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',
]

0 comments on commit 4755733

Please sign in to comment.