#!/usr/bin/env python
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"
import os
import shutil
import tempfile
import unittest
from deid.data import get_dataset
from deid.utils import get_installdir
[docs]class TestDicom(unittest.TestCase):
[docs] def setUp(self):
self.pwd = get_installdir()
self.deid = os.path.abspath("%s/../examples/deid/deid.dicom" % self.pwd)
self.dataset = get_dataset("humans")
self.tmpdir = tempfile.mkdtemp()
print("\n######################START######################")
[docs] def tearDown(self):
shutil.rmtree(self.tmpdir)
print("\n######################END########################")
[docs] def test_get_files(self):
print("Test test_get_files")
print("Case 1: Test get files from dataset")
from deid.dicom import get_files
found = 0
for dicom_file in get_files(self.dataset):
found += 1
expected = 1
self.assertEqual(found, expected)
print("Case 2: Ask for files from empty folder")
found = 0
for dicom_file in get_files(self.tmpdir):
found += 1
expected = 0
self.assertEqual(found, expected)
[docs] def test_get_files_as_list(self):
print("Test test_get_files_as_list")
print("Case 1: Test get files from dataset")
from deid.dicom import get_files
dicom_files = list(get_files(self.dataset))
found = len(dicom_files)
expected = 1
self.assertEqual(found, expected)
print("Case 2: Ask for files from empty folder")
dicom_files = list(get_files(self.tmpdir))
found = len(dicom_files)
expected = 0
self.assertEqual(found, expected)
if __name__ == "__main__":
unittest.main()