test_empty.py 1.57 KB
Newer Older
Mark Hymers's avatar
Mark Hymers committed
1
2
3
4
5
6
#!/usr/bin/python3

# Test the basic class creation and use code

import pytest

Mark Hymers's avatar
Mark Hymers committed
7
8
9
10
11
try:
    from pydicom import read_file
except ImportError:
    from dicom import read_file

Mark Hymers's avatar
Mark Hymers committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
########################################################################
# Empty class tests
########################################################################
class TestCaseStudy:
    def test_create_study(self):
        from yias.dicom import DICOMStudy
        study = DICOMStudy('1.2.3')
        assert(study.studyUID == '1.2.3')

    def test_noseries_study(self):
        from yias.dicom import DICOMStudy
        from yias.errors import YIASNoSeriesError
        study = DICOMStudy('1.2.3')
        with pytest.raises(YIASNoSeriesError):
            study.get_first_series()

class TestCaseSeries:
    def test_create_series(self):
        from yias.dicom import DICOMSeries
        series = DICOMSeries('1.2.3.4')
        assert(series.seriesUID == '1.2.3.4')

    def test_noimage_series(self):
        from yias.dicom import DICOMSeries
        series = DICOMSeries('1.2.3.4')
        with pytest.raises(ValueError):
            series.get_first_property('PatientID')

    def test_image_noproperty(self):
        from os.path import join
        from yias.dicom import DICOMSeries
        from .test_support import TEST_BASEDIR

        series = DICOMSeries('1.2.3.4')
        fname = 'siemens/12/MR.X.1.2.276.0.7230010.3.1.4.2836010529.1187.1490799878.150091'
        series.add_dicom(read_file(join(TEST_BASEDIR, fname)))
        with pytest.raises(ValueError):
            series.get_first_property('PatientID2')