From 1ef87fa14cb93473d7594727efda75eaa4a8e6bd Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Wed, 15 Apr 2020 16:34:14 -0400 Subject: [PATCH] initial checkin of test_dicomutils still needs more coverage of the functions in dicomutils --- tests/test_dicomutils.py | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 tests/test_dicomutils.py diff --git a/tests/test_dicomutils.py b/tests/test_dicomutils.py new file mode 100755 index 0000000..a4f7828 --- /dev/null +++ b/tests/test_dicomutils.py @@ -0,0 +1,48 @@ +#! /usr/bin/env python + +import unittest +import os, shutil +from utils import dicomutils +import vtk +import SimpleITK as sitk +from tests import create_data +from tests import write_series + +class TestDicomUtils(unittest.TestCase): + + TMPDIR = "testtmp" + + def setUp(self): + print("\nBuildin\' it up!") + cyl = create_data.make_cylinder(32, sitk.sitkUInt16) + try: + os.mkdir(self.TMPDIR) + except: + print("Oopsie") + write_series.write_series( cyl, self.TMPDIR ) + + + def tearDown(self): + print("\nTearin\' it down!") + shutil.rmtree(self.TMPDIR) + + def test_dicomutils(self): + + print("\nTesting DicomUtils.scanDirForDicom") + matches, dirs = dicomutils.scanDirForDicom(self.TMPDIR) + print(matches, dirs) + self.assertEqual(len(matches), 32) + + print("\nTesting DicomUtils.getAllSeries") + seriessets = dicomutils.getAllSeries([self.TMPDIR]) + print(seriessets) + self.assertEqual(len(seriessets),1) + series_id = seriessets[0][0] + if series_id.startswith('1.2.826.0.1.3680043'): + print(" Series looks good") + else: + self.fail(" Bad series: "+series_id) + +if __name__ == "__main__": + unittest.main() +