Commit 2b5c3c36 authored by Gabriel Couture's avatar Gabriel Couture

Adding tests to test_dao

parent ac0c755e
......@@ -5,10 +5,13 @@ import unittest
import pydicom
from dicomgenerator import dao
from dicomgenerator.exceptions import WrongGeometryError, InvalidDoseGradientError
A_GEOMETRY = 'cones'
A_SPACING = 1.0
A_DOSE_GRADIENTS = 'AP'
A_BAD_GEOMETRY = 'A_BAD_GEOMETRY'
A_BAD_DOSE_GRADIENT = 'A_BAD_DOSE_GRADIENT'
class TestDao(unittest.TestCase):
......@@ -20,9 +23,21 @@ class TestDao(unittest.TestCase):
self.assertIsInstance(result[0], pydicom.FileDataset)
self.assertEqual(result[0]['Modality'].value, 'RTSTRUCT')
def test_givenAGAndASpacing_whenGettingRtdose_thenResultIsOneRtdoseFileDataSet(self):
def test_givenAGeometryAndASpacing_whenGettingRtstruct_thenRaiseWrongGeometryError(self):
self.assertRaises(
WrongGeometryError,
lambda: dao.get_rtstruct(A_BAD_GEOMETRY, A_SPACING)
)
def test_givenADoseGradientAndASpacing_whenGettingRtdose_thenResultIsOneRtdoseFileDataSet(self):
result = dao.get_rtdose(A_DOSE_GRADIENTS, A_SPACING)
self.assertEqual(len(result), 1)
self.assertIsInstance(result[0], pydicom.FileDataset)
self.assertEqual(result[0]['Modality'].value, 'RTDOSE')
def test_givenADoseGradientAndASpacing_whenGettingRtstruct_thenRaiseWrongGeometryError(self):
self.assertRaises(
InvalidDoseGradientError,
lambda: dao.get_rtdose(A_BAD_GEOMETRY, A_SPACING)
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment